<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>SDL2_gfx: I:/Sources/sdl2gfx/SDL2_gfxPrimitives.c Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">SDL2_gfx
   &#160;<span id="projectnumber">1.0.1</span>
   </div>
   <div id="projectbrief">GraphicsprimitivesandsurfacefunctionsforSDL2</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">I:/Sources/sdl2gfx/SDL2_gfxPrimitives.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_s_d_l2__gfx_primitives_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* </span>
<a name="l00002"></a>00002 <span class="comment"></span>
<a name="l00003"></a>00003 <span class="comment">SDL2_gfxPrimitives.c: graphics primitives for SDL2 renderers</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment">Copyright (C) 2012  Andreas Schiffler</span>
<a name="l00006"></a>00006 <span class="comment"></span>
<a name="l00007"></a>00007 <span class="comment">This software is provided &#39;as-is&#39;, without any express or implied</span>
<a name="l00008"></a>00008 <span class="comment">warranty. In no event will the authors be held liable for any damages</span>
<a name="l00009"></a>00009 <span class="comment">arising from the use of this software.</span>
<a name="l00010"></a>00010 <span class="comment"></span>
<a name="l00011"></a>00011 <span class="comment">Permission is granted to anyone to use this software for any purpose,</span>
<a name="l00012"></a>00012 <span class="comment">including commercial applications, and to alter it and redistribute it</span>
<a name="l00013"></a>00013 <span class="comment">freely, subject to the following restrictions:</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">1. The origin of this software must not be misrepresented; you must not</span>
<a name="l00016"></a>00016 <span class="comment">claim that you wrote the original software. If you use this software</span>
<a name="l00017"></a>00017 <span class="comment">in a product, an acknowledgment in the product documentation would be</span>
<a name="l00018"></a>00018 <span class="comment">appreciated but is not required.</span>
<a name="l00019"></a>00019 <span class="comment"></span>
<a name="l00020"></a>00020 <span class="comment">2. Altered source versions must be plainly marked as such, and must not be</span>
<a name="l00021"></a>00021 <span class="comment">misrepresented as being the original software.</span>
<a name="l00022"></a>00022 <span class="comment"></span>
<a name="l00023"></a>00023 <span class="comment">3. This notice may not be removed or altered from any source</span>
<a name="l00024"></a>00024 <span class="comment">distribution.</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">Andreas Schiffler -- aschiffler at ferzkopp dot net</span>
<a name="l00027"></a>00027 <span class="comment"></span>
<a name="l00028"></a>00028 <span class="comment">*/</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="_s_d_l2__gfx_primitives_8h.html">SDL2_gfxPrimitives.h</a>&quot;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &quot;<a class="code" href="_s_d_l2__rotozoom_8h.html">SDL2_rotozoom.h</a>&quot;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &quot;<a class="code" href="_s_d_l2__gfx_primitives__font_8h.html">SDL2_gfxPrimitives_font.h</a>&quot;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="comment">/* ---- Structures */</span>
<a name="l00040"></a>00040 
<a name="l00044"></a><a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00045"></a><a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">00045</a>         Sint16 x, <a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a>;
<a name="l00046"></a><a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ace147c79e29f2efd14e5744efcb976af">00046</a>         <span class="keywordtype">int</span> dx, dy, s1, s2, <a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ace147c79e29f2efd14e5744efcb976af">swapdir</a>, error;
<a name="l00047"></a><a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a92fcd448f278df155fd5472527a6dc47">00047</a>         Uint32 <a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a92fcd448f278df155fd5472527a6dc47">count</a>;
<a name="l00048"></a>00048 } <a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html" title="The structure passed to the internal Bresenham iterator.">SDL2_gfxBresenhamIterator</a>;
<a name="l00049"></a>00049 
<a name="l00053"></a><a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html">00053</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00054"></a><a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">00054</a>         SDL_Renderer *<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a>;
<a name="l00055"></a><a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">00055</a>         <span class="keywordtype">int</span> u, <a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a>;               <span class="comment">/* delta x , delta y */</span>
<a name="l00056"></a><a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">00056</a>         <span class="keywordtype">int</span> ku, kt, <a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a>, kd;     <span class="comment">/* loop constants */</span>
<a name="l00057"></a><a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">00057</a>         <span class="keywordtype">int</span> <a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a>;
<a name="l00058"></a><a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">00058</a>         <span class="keywordtype">int</span> <a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a>;
<a name="l00059"></a><a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a4c3e88fc7abb5715d04e28d96a154e5f">00059</a>         Sint16 last1x, last1y, last2x, last2y, first1x, first1y, first2x, first2y, tempx, <a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a4c3e88fc7abb5715d04e28d96a154e5f">tempy</a>;
<a name="l00060"></a>00060 } <a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html" title="The structure passed to the internal Murphy iterator.">SDL2_gfxMurphyIterator</a>;
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 <span class="comment">/* ---- Pixel */</span>
<a name="l00063"></a>00063 
<a name="l00073"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8">00073</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(SDL_Renderer *renderer, Sint16 x, Sint16 y)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075         <span class="keywordflow">return</span> SDL_RenderDrawPoint(renderer, x, y);
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 
<a name="l00088"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a2bdb83ac58c2e091ef26f720bdeb66bd">00088</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a345d35905f5aaac6029ddc3c8f016402" title="Draw pixel with blending enabled if a&lt;255.">pixelColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Uint32 color)
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00091"></a>00091         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x, y, c[0], c[1], c[2], c[3]);
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093 
<a name="l00107"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a6f4a05ba92bf39420280ee8ccf961e77">00107</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00108"></a>00108 {
<a name="l00109"></a>00109         <span class="keywordtype">int</span> result = 0;
<a name="l00110"></a>00110         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l00111"></a>00111         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l00112"></a>00112         result |= SDL_RenderDrawPoint(renderer, x, y);
<a name="l00113"></a>00113         <span class="keywordflow">return</span> result;
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 
<a name="l00130"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf">00130</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a, Uint32 weight)
<a name="l00131"></a>00131 {
<a name="l00132"></a>00132         <span class="comment">/*</span>
<a name="l00133"></a>00133 <span class="comment">        * Modify Alpha by weight </span>
<a name="l00134"></a>00134 <span class="comment">        */</span>
<a name="l00135"></a>00135         Uint32 ax = a;
<a name="l00136"></a>00136         ax = ((ax * weight) &gt;&gt; 8);
<a name="l00137"></a>00137         <span class="keywordflow">if</span> (ax &gt; 255) {
<a name="l00138"></a>00138                 a = 255;
<a name="l00139"></a>00139         } <span class="keywordflow">else</span> {
<a name="l00140"></a>00140                 a = (Uint8)(ax &amp; 0x000000ff);
<a name="l00141"></a>00141         }
<a name="l00142"></a>00142 
<a name="l00143"></a>00143         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x, y, r, g, b, a);
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 <span class="comment">/* ---- Hline */</span>
<a name="l00147"></a>00147 
<a name="l00158"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9">00158</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 x2, Sint16 y)
<a name="l00159"></a>00159 {
<a name="l00160"></a>00160         <span class="keywordflow">return</span> SDL_RenderDrawLine(renderer, x1, y, x2, y);;
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 
<a name="l00175"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a0d1977c09c0bcfe77b4e1a792ce1e79a">00175</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7db92d9e3d357e5a81ae1eee59a6d44a" title="Draw horizontal line with blending.">hlineColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color)
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00178"></a>00178         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x1, x2, y, c[0], c[1], c[2], c[3]);
<a name="l00179"></a>00179 }
<a name="l00180"></a>00180 
<a name="l00195"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#ace5a96b77edbccba3170852b093503aa">00195</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00196"></a>00196 {
<a name="l00197"></a>00197         <span class="keywordtype">int</span> result = 0;
<a name="l00198"></a>00198         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l00199"></a>00199         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l00200"></a>00200         result |= SDL_RenderDrawLine(renderer, x1, y, x2, y);
<a name="l00201"></a>00201         <span class="keywordflow">return</span> result;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 
<a name="l00204"></a>00204 <span class="comment">/* ---- Vline */</span>
<a name="l00205"></a>00205 
<a name="l00217"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#af8cf6591ddc81242369e50cb3e159dfe">00217</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a743ef67a072a56f575e555feaf1eeb58" title="Draw vertical line with blending.">vlineColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color)
<a name="l00218"></a>00218 {
<a name="l00219"></a>00219         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00220"></a>00220         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x, y1, y2, c[0], c[1], c[2], c[3]);
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222 
<a name="l00237"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a60d71d2bc6e450d8063256ebc37f21f5">00237</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00238"></a>00238 {
<a name="l00239"></a>00239         <span class="keywordtype">int</span> result = 0;
<a name="l00240"></a>00240         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l00241"></a>00241         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l00242"></a>00242         result |= SDL_RenderDrawLine(renderer, x, y1, x, y2);
<a name="l00243"></a>00243         <span class="keywordflow">return</span> result;
<a name="l00244"></a>00244 }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246 <span class="comment">/* ---- Rectangle */</span>
<a name="l00247"></a>00247 
<a name="l00260"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a53b996645c0acdf5cb74c969503e791e">00260</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a746d7d6cbec9dbe69d27ec9087e7bf92" title="Draw rectangle with blending.">rectangleColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
<a name="l00261"></a>00261 {
<a name="l00262"></a>00262         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00263"></a>00263         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a22bb0fffd73e6afbe899db10b13a40cf" title="Draw rectangle with blending.">rectangleRGBA</a>(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265 
<a name="l00281"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#aa926924c3650d10d6a20cd7e4036a9a4">00281</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a22bb0fffd73e6afbe899db10b13a40cf" title="Draw rectangle with blending.">rectangleRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00282"></a>00282 {
<a name="l00283"></a>00283         <span class="keywordtype">int</span> result;
<a name="l00284"></a>00284         Sint16 tmp;
<a name="l00285"></a>00285         SDL_Rect rect;
<a name="l00286"></a>00286 
<a name="l00287"></a>00287         <span class="comment">/*</span>
<a name="l00288"></a>00288 <span class="comment">        * Test for special cases of straight lines or single point </span>
<a name="l00289"></a>00289 <span class="comment">        */</span>
<a name="l00290"></a>00290         <span class="keywordflow">if</span> (x1 == x2) {
<a name="l00291"></a>00291                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00292"></a>00292                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x1, y1, r, g, b, a));
<a name="l00293"></a>00293                 } <span class="keywordflow">else</span> {
<a name="l00294"></a>00294                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x1, y1, y2, r, g, b, a));
<a name="l00295"></a>00295                 }
<a name="l00296"></a>00296         } <span class="keywordflow">else</span> {
<a name="l00297"></a>00297                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00298"></a>00298                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x1, x2, y1, r, g, b, a));
<a name="l00299"></a>00299                 }
<a name="l00300"></a>00300         }
<a name="l00301"></a>00301 
<a name="l00302"></a>00302         <span class="comment">/*</span>
<a name="l00303"></a>00303 <span class="comment">        * Swap x1, x2 if required </span>
<a name="l00304"></a>00304 <span class="comment">        */</span>
<a name="l00305"></a>00305         <span class="keywordflow">if</span> (x1 &gt; x2) {
<a name="l00306"></a>00306                 tmp = x1;
<a name="l00307"></a>00307                 x1 = x2;
<a name="l00308"></a>00308                 x2 = tmp;
<a name="l00309"></a>00309         }
<a name="l00310"></a>00310 
<a name="l00311"></a>00311         <span class="comment">/*</span>
<a name="l00312"></a>00312 <span class="comment">        * Swap y1, y2 if required </span>
<a name="l00313"></a>00313 <span class="comment">        */</span>
<a name="l00314"></a>00314         <span class="keywordflow">if</span> (y1 &gt; y2) {
<a name="l00315"></a>00315                 tmp = y1;
<a name="l00316"></a>00316                 y1 = y2;
<a name="l00317"></a>00317                 y2 = tmp;
<a name="l00318"></a>00318         }
<a name="l00319"></a>00319 
<a name="l00320"></a>00320         <span class="comment">/* </span>
<a name="l00321"></a>00321 <span class="comment">        * Create destination rect</span>
<a name="l00322"></a>00322 <span class="comment">        */</span>      
<a name="l00323"></a>00323         rect.x = x1;
<a name="l00324"></a>00324         rect.y = y1;
<a name="l00325"></a>00325         rect.w = x2 - x1;
<a name="l00326"></a>00326         rect.h = y2 - y1;
<a name="l00327"></a>00327         
<a name="l00328"></a>00328         <span class="comment">/*</span>
<a name="l00329"></a>00329 <span class="comment">        * Draw</span>
<a name="l00330"></a>00330 <span class="comment">        */</span>
<a name="l00331"></a>00331         result = 0;
<a name="l00332"></a>00332         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l00333"></a>00333         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a); 
<a name="l00334"></a>00334         result |= SDL_RenderDrawRect(renderer, &amp;rect);
<a name="l00335"></a>00335         <span class="keywordflow">return</span> result;
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 
<a name="l00338"></a>00338 <span class="comment">/* ---- Rounded Rectangle */</span>
<a name="l00339"></a>00339 
<a name="l00353"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a314698defb7da3f3415ddc5468315d83">00353</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa959f94f887900f4554a0cdff23dad38" title="Draw rounded-corner rectangle with blending.">roundedRectangleColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
<a name="l00354"></a>00354 {
<a name="l00355"></a>00355         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00356"></a>00356         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a97474c00a6b7b26353b7875e6c70e802" title="Draw rounded-corner rectangle with blending.">roundedRectangleRGBA</a>(renderer, x1, y1, x2, y2, rad, c[0], c[1], c[2], c[3]);
<a name="l00357"></a>00357 }
<a name="l00358"></a>00358 
<a name="l00375"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a2b54ba16d7e7243fb1921a286156cad9">00375</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a97474c00a6b7b26353b7875e6c70e802" title="Draw rounded-corner rectangle with blending.">roundedRectangleRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00376"></a>00376 {
<a name="l00377"></a>00377         <span class="keywordtype">int</span> result = 0;
<a name="l00378"></a>00378         Sint16 tmp;
<a name="l00379"></a>00379         Sint16 w, h;
<a name="l00380"></a>00380         Sint16 xx1, xx2;
<a name="l00381"></a>00381         Sint16 yy1, yy2;
<a name="l00382"></a>00382         
<a name="l00383"></a>00383         <span class="comment">/*</span>
<a name="l00384"></a>00384 <span class="comment">        * Check renderer</span>
<a name="l00385"></a>00385 <span class="comment">        */</span>
<a name="l00386"></a>00386         <span class="keywordflow">if</span> (renderer == NULL)
<a name="l00387"></a>00387         {
<a name="l00388"></a>00388                 <span class="keywordflow">return</span> -1;
<a name="l00389"></a>00389         }
<a name="l00390"></a>00390 
<a name="l00391"></a>00391         <span class="comment">/*</span>
<a name="l00392"></a>00392 <span class="comment">        * Check radius vor valid range</span>
<a name="l00393"></a>00393 <span class="comment">        */</span>
<a name="l00394"></a>00394         <span class="keywordflow">if</span> (rad &lt; 0) {
<a name="l00395"></a>00395                 <span class="keywordflow">return</span> -1;
<a name="l00396"></a>00396         }
<a name="l00397"></a>00397 
<a name="l00398"></a>00398         <span class="comment">/*</span>
<a name="l00399"></a>00399 <span class="comment">        * Special case - no rounding</span>
<a name="l00400"></a>00400 <span class="comment">        */</span>
<a name="l00401"></a>00401         <span class="keywordflow">if</span> (rad &lt;= 1) {
<a name="l00402"></a>00402                 <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a22bb0fffd73e6afbe899db10b13a40cf" title="Draw rectangle with blending.">rectangleRGBA</a>(renderer, x1, y1, x2, y2, r, g, b, a);
<a name="l00403"></a>00403         }
<a name="l00404"></a>00404 
<a name="l00405"></a>00405         <span class="comment">/*</span>
<a name="l00406"></a>00406 <span class="comment">        * Test for special cases of straight lines or single point </span>
<a name="l00407"></a>00407 <span class="comment">        */</span>
<a name="l00408"></a>00408         <span class="keywordflow">if</span> (x1 == x2) {
<a name="l00409"></a>00409                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00410"></a>00410                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x1, y1, r, g, b, a));
<a name="l00411"></a>00411                 } <span class="keywordflow">else</span> {
<a name="l00412"></a>00412                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x1, y1, y2, r, g, b, a));
<a name="l00413"></a>00413                 }
<a name="l00414"></a>00414         } <span class="keywordflow">else</span> {
<a name="l00415"></a>00415                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00416"></a>00416                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x1, x2, y1, r, g, b, a));
<a name="l00417"></a>00417                 }
<a name="l00418"></a>00418         }
<a name="l00419"></a>00419 
<a name="l00420"></a>00420         <span class="comment">/*</span>
<a name="l00421"></a>00421 <span class="comment">        * Swap x1, x2 if required </span>
<a name="l00422"></a>00422 <span class="comment">        */</span>
<a name="l00423"></a>00423         <span class="keywordflow">if</span> (x1 &gt; x2) {
<a name="l00424"></a>00424                 tmp = x1;
<a name="l00425"></a>00425                 x1 = x2;
<a name="l00426"></a>00426                 x2 = tmp;
<a name="l00427"></a>00427         }
<a name="l00428"></a>00428 
<a name="l00429"></a>00429         <span class="comment">/*</span>
<a name="l00430"></a>00430 <span class="comment">        * Swap y1, y2 if required </span>
<a name="l00431"></a>00431 <span class="comment">        */</span>
<a name="l00432"></a>00432         <span class="keywordflow">if</span> (y1 &gt; y2) {
<a name="l00433"></a>00433                 tmp = y1;
<a name="l00434"></a>00434                 y1 = y2;
<a name="l00435"></a>00435                 y2 = tmp;
<a name="l00436"></a>00436         }
<a name="l00437"></a>00437 
<a name="l00438"></a>00438         <span class="comment">/*</span>
<a name="l00439"></a>00439 <span class="comment">        * Calculate width&amp;height </span>
<a name="l00440"></a>00440 <span class="comment">        */</span>
<a name="l00441"></a>00441         w = x2 - x1;
<a name="l00442"></a>00442         h = y2 - y1;
<a name="l00443"></a>00443 
<a name="l00444"></a>00444         <span class="comment">/*</span>
<a name="l00445"></a>00445 <span class="comment">        * Maybe adjust radius</span>
<a name="l00446"></a>00446 <span class="comment">        */</span>
<a name="l00447"></a>00447         <span class="keywordflow">if</span> ((rad * 2) &gt; w)  
<a name="l00448"></a>00448         {
<a name="l00449"></a>00449                 rad = w / 2;
<a name="l00450"></a>00450         }
<a name="l00451"></a>00451         <span class="keywordflow">if</span> ((rad * 2) &gt; h)
<a name="l00452"></a>00452         {
<a name="l00453"></a>00453                 rad = h / 2;
<a name="l00454"></a>00454         }
<a name="l00455"></a>00455 
<a name="l00456"></a>00456         <span class="comment">/*</span>
<a name="l00457"></a>00457 <span class="comment">        * Draw corners</span>
<a name="l00458"></a>00458 <span class="comment">        */</span>
<a name="l00459"></a>00459         xx1 = x1 + rad;
<a name="l00460"></a>00460         xx2 = x2 - rad;
<a name="l00461"></a>00461         yy1 = y1 + rad;
<a name="l00462"></a>00462         yy2 = y2 - rad;
<a name="l00463"></a>00463         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a0445c87dd018fe7f26c0343bb1545cc5" title="Arc with blending.">arcRGBA</a>(renderer, xx1, yy1, rad, 180, 270, r, g, b, a);
<a name="l00464"></a>00464         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a0445c87dd018fe7f26c0343bb1545cc5" title="Arc with blending.">arcRGBA</a>(renderer, xx2, yy1, rad, 270, 360, r, g, b, a);
<a name="l00465"></a>00465         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a0445c87dd018fe7f26c0343bb1545cc5" title="Arc with blending.">arcRGBA</a>(renderer, xx1, yy2, rad,  90, 180, r, g, b, a);
<a name="l00466"></a>00466         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a0445c87dd018fe7f26c0343bb1545cc5" title="Arc with blending.">arcRGBA</a>(renderer, xx2, yy2, rad,   0,  90, r, g, b, a);
<a name="l00467"></a>00467 
<a name="l00468"></a>00468         <span class="comment">/*</span>
<a name="l00469"></a>00469 <span class="comment">        * Draw lines</span>
<a name="l00470"></a>00470 <span class="comment">        */</span>
<a name="l00471"></a>00471         <span class="keywordflow">if</span> (xx1 &lt;= xx2) {
<a name="l00472"></a>00472                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, xx1, xx2, y1, r, g, b, a);
<a name="l00473"></a>00473                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, xx1, xx2, y2, r, g, b, a);
<a name="l00474"></a>00474         }
<a name="l00475"></a>00475         <span class="keywordflow">if</span> (yy1 &lt;= yy2) {
<a name="l00476"></a>00476                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x1, yy1, yy2, r, g, b, a);
<a name="l00477"></a>00477                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x2, yy1, yy2, r, g, b, a);
<a name="l00478"></a>00478         }
<a name="l00479"></a>00479 
<a name="l00480"></a>00480         <span class="keywordflow">return</span> result;
<a name="l00481"></a>00481 }
<a name="l00482"></a>00482 
<a name="l00483"></a>00483 <span class="comment">/* ---- Rounded Box */</span>
<a name="l00484"></a>00484 
<a name="l00498"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a13ffcecd9c186d2522ae1e66bdedf8d7">00498</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a054bef5fbc340a7bc6a19396e02af7f5" title="Draw rounded-corner box (filled rectangle) with blending.">roundedBoxColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color)
<a name="l00499"></a>00499 {
<a name="l00500"></a>00500         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00501"></a>00501         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa0dcfdfa750ba9fe6b0c207f451d5a68" title="Draw rounded-corner box (filled rectangle) with blending.">roundedBoxRGBA</a>(renderer, x1, y1, x2, y2, rad, c[0], c[1], c[2], c[3]);
<a name="l00502"></a>00502 }
<a name="l00503"></a>00503 
<a name="l00520"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a3db064ca0f03a2c46852661494ff7a65">00520</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa0dcfdfa750ba9fe6b0c207f451d5a68" title="Draw rounded-corner box (filled rectangle) with blending.">roundedBoxRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2,
<a name="l00521"></a>00521         Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00522"></a>00522 {
<a name="l00523"></a>00523         <span class="keywordtype">int</span> result;
<a name="l00524"></a>00524         Sint16 w, h, r2, tmp;
<a name="l00525"></a>00525         Sint16 cx = 0;
<a name="l00526"></a>00526         Sint16 cy = rad;
<a name="l00527"></a>00527         Sint16 ocx = (Sint16) 0xffff;
<a name="l00528"></a>00528         Sint16 ocy = (Sint16) 0xffff;
<a name="l00529"></a>00529         Sint16 df = 1 - rad;
<a name="l00530"></a>00530         Sint16 d_e = 3;
<a name="l00531"></a>00531         Sint16 d_se = -2 * rad + 5;
<a name="l00532"></a>00532         Sint16 xpcx, xmcx, xpcy, xmcy;
<a name="l00533"></a>00533         Sint16 ypcy, ymcy, ypcx, ymcx;
<a name="l00534"></a>00534         Sint16 x, y, dx, dy;
<a name="l00535"></a>00535 
<a name="l00536"></a>00536         <span class="comment">/* </span>
<a name="l00537"></a>00537 <span class="comment">        * Check destination renderer </span>
<a name="l00538"></a>00538 <span class="comment">        */</span>
<a name="l00539"></a>00539         <span class="keywordflow">if</span> (renderer == NULL)
<a name="l00540"></a>00540         {
<a name="l00541"></a>00541                 <span class="keywordflow">return</span> -1;
<a name="l00542"></a>00542         }
<a name="l00543"></a>00543 
<a name="l00544"></a>00544         <span class="comment">/*</span>
<a name="l00545"></a>00545 <span class="comment">        * Check radius vor valid range</span>
<a name="l00546"></a>00546 <span class="comment">        */</span>
<a name="l00547"></a>00547         <span class="keywordflow">if</span> (rad &lt; 0) {
<a name="l00548"></a>00548                 <span class="keywordflow">return</span> -1;
<a name="l00549"></a>00549         }
<a name="l00550"></a>00550 
<a name="l00551"></a>00551         <span class="comment">/*</span>
<a name="l00552"></a>00552 <span class="comment">        * Special case - no rounding</span>
<a name="l00553"></a>00553 <span class="comment">        */</span>
<a name="l00554"></a>00554         <span class="keywordflow">if</span> (rad &lt;= 1) {
<a name="l00555"></a>00555                 <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a22bb0fffd73e6afbe899db10b13a40cf" title="Draw rectangle with blending.">rectangleRGBA</a>(renderer, x1, y1, x2, y2, r, g, b, a);
<a name="l00556"></a>00556         }
<a name="l00557"></a>00557 
<a name="l00558"></a>00558         <span class="comment">/*</span>
<a name="l00559"></a>00559 <span class="comment">        * Test for special cases of straight lines or single point </span>
<a name="l00560"></a>00560 <span class="comment">        */</span>
<a name="l00561"></a>00561         <span class="keywordflow">if</span> (x1 == x2) {
<a name="l00562"></a>00562                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00563"></a>00563                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x1, y1, r, g, b, a));
<a name="l00564"></a>00564                 } <span class="keywordflow">else</span> {
<a name="l00565"></a>00565                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x1, y1, y2, r, g, b, a));
<a name="l00566"></a>00566                 }
<a name="l00567"></a>00567         } <span class="keywordflow">else</span> {
<a name="l00568"></a>00568                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00569"></a>00569                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x1, x2, y1, r, g, b, a));
<a name="l00570"></a>00570                 }
<a name="l00571"></a>00571         }
<a name="l00572"></a>00572 
<a name="l00573"></a>00573         <span class="comment">/*</span>
<a name="l00574"></a>00574 <span class="comment">        * Swap x1, x2 if required </span>
<a name="l00575"></a>00575 <span class="comment">        */</span>
<a name="l00576"></a>00576         <span class="keywordflow">if</span> (x1 &gt; x2) {
<a name="l00577"></a>00577                 tmp = x1;
<a name="l00578"></a>00578                 x1 = x2;
<a name="l00579"></a>00579                 x2 = tmp;
<a name="l00580"></a>00580         }
<a name="l00581"></a>00581 
<a name="l00582"></a>00582         <span class="comment">/*</span>
<a name="l00583"></a>00583 <span class="comment">        * Swap y1, y2 if required </span>
<a name="l00584"></a>00584 <span class="comment">        */</span>
<a name="l00585"></a>00585         <span class="keywordflow">if</span> (y1 &gt; y2) {
<a name="l00586"></a>00586                 tmp = y1;
<a name="l00587"></a>00587                 y1 = y2;
<a name="l00588"></a>00588                 y2 = tmp;
<a name="l00589"></a>00589         }
<a name="l00590"></a>00590 
<a name="l00591"></a>00591         <span class="comment">/*</span>
<a name="l00592"></a>00592 <span class="comment">        * Calculate width&amp;height </span>
<a name="l00593"></a>00593 <span class="comment">        */</span>
<a name="l00594"></a>00594         w = x2 - x1 + 1;
<a name="l00595"></a>00595         h = y2 - y1 + 1;
<a name="l00596"></a>00596 
<a name="l00597"></a>00597         <span class="comment">/*</span>
<a name="l00598"></a>00598 <span class="comment">        * Maybe adjust radius</span>
<a name="l00599"></a>00599 <span class="comment">        */</span>
<a name="l00600"></a>00600         r2 = rad + rad;
<a name="l00601"></a>00601         <span class="keywordflow">if</span> (r2 &gt; w)  
<a name="l00602"></a>00602         {
<a name="l00603"></a>00603                 rad = w / 2;
<a name="l00604"></a>00604                 r2 = rad + rad;
<a name="l00605"></a>00605         }
<a name="l00606"></a>00606         <span class="keywordflow">if</span> (r2 &gt; h)
<a name="l00607"></a>00607         {
<a name="l00608"></a>00608                 rad = h / 2;
<a name="l00609"></a>00609         }
<a name="l00610"></a>00610 
<a name="l00611"></a>00611         <span class="comment">/* Setup filled circle drawing for corners */</span>
<a name="l00612"></a>00612         x = x1 + rad;
<a name="l00613"></a>00613         y = y1 + rad;
<a name="l00614"></a>00614         dx = x2 - x1 - rad - rad;
<a name="l00615"></a>00615         dy = y2 - y1 - rad - rad;
<a name="l00616"></a>00616 
<a name="l00617"></a>00617         <span class="comment">/*</span>
<a name="l00618"></a>00618 <span class="comment">        * Set color</span>
<a name="l00619"></a>00619 <span class="comment">        */</span>
<a name="l00620"></a>00620         result = 0;
<a name="l00621"></a>00621         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l00622"></a>00622         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l00623"></a>00623 
<a name="l00624"></a>00624         <span class="comment">/*</span>
<a name="l00625"></a>00625 <span class="comment">        * Draw corners</span>
<a name="l00626"></a>00626 <span class="comment">        */</span>
<a name="l00627"></a>00627         <span class="keywordflow">do</span> {
<a name="l00628"></a>00628                 xpcx = x + cx;
<a name="l00629"></a>00629                 xmcx = x - cx;
<a name="l00630"></a>00630                 xpcy = x + cy;
<a name="l00631"></a>00631                 xmcy = x - cy;
<a name="l00632"></a>00632                 <span class="keywordflow">if</span> (ocy != cy) {
<a name="l00633"></a>00633                         <span class="keywordflow">if</span> (cy &gt; 0) {
<a name="l00634"></a>00634                                 ypcy = y + cy;
<a name="l00635"></a>00635                                 ymcy = y - cy;
<a name="l00636"></a>00636                                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcx, xpcx + dx, ypcy + dy);
<a name="l00637"></a>00637                                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcx, xpcx + dx, ymcy);
<a name="l00638"></a>00638                         } <span class="keywordflow">else</span> {
<a name="l00639"></a>00639                                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcx, xpcx + dx, y);
<a name="l00640"></a>00640                         }
<a name="l00641"></a>00641                         ocy = cy;
<a name="l00642"></a>00642                 }
<a name="l00643"></a>00643                 <span class="keywordflow">if</span> (ocx != cx) {
<a name="l00644"></a>00644                         <span class="keywordflow">if</span> (cx != cy) {
<a name="l00645"></a>00645                                 <span class="keywordflow">if</span> (cx &gt; 0) {
<a name="l00646"></a>00646                                         ypcx = y + cx;
<a name="l00647"></a>00647                                         ymcx = y - cx;
<a name="l00648"></a>00648                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcy, xpcy + dx, ymcx);
<a name="l00649"></a>00649                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcy, xpcy + dx, ypcx + dy);
<a name="l00650"></a>00650                                 } <span class="keywordflow">else</span> {
<a name="l00651"></a>00651                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcy, xpcy + dx, y);
<a name="l00652"></a>00652                                 }
<a name="l00653"></a>00653                         }
<a name="l00654"></a>00654                         ocx = cx;
<a name="l00655"></a>00655                 }
<a name="l00656"></a>00656 
<a name="l00657"></a>00657                 <span class="comment">/*</span>
<a name="l00658"></a>00658 <span class="comment">                * Update </span>
<a name="l00659"></a>00659 <span class="comment">                */</span>
<a name="l00660"></a>00660                 <span class="keywordflow">if</span> (df &lt; 0) {
<a name="l00661"></a>00661                         df += d_e;
<a name="l00662"></a>00662                         d_e += 2;
<a name="l00663"></a>00663                         d_se += 2;
<a name="l00664"></a>00664                 } <span class="keywordflow">else</span> {
<a name="l00665"></a>00665                         df += d_se;
<a name="l00666"></a>00666                         d_e += 2;
<a name="l00667"></a>00667                         d_se += 4;
<a name="l00668"></a>00668                         cy--;
<a name="l00669"></a>00669                 }
<a name="l00670"></a>00670                 cx++;
<a name="l00671"></a>00671         } <span class="keywordflow">while</span> (cx &lt;= cy);
<a name="l00672"></a>00672 
<a name="l00673"></a>00673         <span class="comment">/* Inside */</span>
<a name="l00674"></a>00674         <span class="keywordflow">if</span> (dx &gt; 0 &amp;&amp; dy &gt; 0) {
<a name="l00675"></a>00675                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6c26ea8c03d1092f917665a182b91963" title="Draw box (filled rectangle) with blending.">boxRGBA</a>(renderer, x1, y1 + rad + 1, x2, y2 - rad, r, g, b, a);
<a name="l00676"></a>00676         }
<a name="l00677"></a>00677 
<a name="l00678"></a>00678         <span class="keywordflow">return</span> (result);
<a name="l00679"></a>00679 }
<a name="l00680"></a>00680 
<a name="l00681"></a>00681 <span class="comment">/* ---- Box */</span>
<a name="l00682"></a>00682 
<a name="l00695"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a5799b0d1e99252b19d9acc77e7a94541">00695</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#af0cabe8d3a5e7cf4c95f436c4b87284d" title="Draw box (filled rectangle) with blending.">boxColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
<a name="l00696"></a>00696 {
<a name="l00697"></a>00697         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00698"></a>00698         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6c26ea8c03d1092f917665a182b91963" title="Draw box (filled rectangle) with blending.">boxRGBA</a>(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
<a name="l00699"></a>00699 }
<a name="l00700"></a>00700 
<a name="l00716"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a903bb79c5a03077047ff8820df263bd8">00716</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6c26ea8c03d1092f917665a182b91963" title="Draw box (filled rectangle) with blending.">boxRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00717"></a>00717 {
<a name="l00718"></a>00718         <span class="keywordtype">int</span> result;
<a name="l00719"></a>00719         Sint16 tmp;
<a name="l00720"></a>00720         SDL_Rect rect;
<a name="l00721"></a>00721 
<a name="l00722"></a>00722         <span class="comment">/*</span>
<a name="l00723"></a>00723 <span class="comment">        * Test for special cases of straight lines or single point </span>
<a name="l00724"></a>00724 <span class="comment">        */</span>
<a name="l00725"></a>00725         <span class="keywordflow">if</span> (x1 == x2) {
<a name="l00726"></a>00726                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00727"></a>00727                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x1, y1, r, g, b, a));
<a name="l00728"></a>00728                 } <span class="keywordflow">else</span> {
<a name="l00729"></a>00729                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x1, y1, y2, r, g, b, a));
<a name="l00730"></a>00730                 }
<a name="l00731"></a>00731         } <span class="keywordflow">else</span> {
<a name="l00732"></a>00732                 <span class="keywordflow">if</span> (y1 == y2) {
<a name="l00733"></a>00733                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x1, x2, y1, r, g, b, a));
<a name="l00734"></a>00734                 }
<a name="l00735"></a>00735         }
<a name="l00736"></a>00736 
<a name="l00737"></a>00737         <span class="comment">/*</span>
<a name="l00738"></a>00738 <span class="comment">        * Swap x1, x2 if required </span>
<a name="l00739"></a>00739 <span class="comment">        */</span>
<a name="l00740"></a>00740         <span class="keywordflow">if</span> (x1 &gt; x2) {
<a name="l00741"></a>00741                 tmp = x1;
<a name="l00742"></a>00742                 x1 = x2;
<a name="l00743"></a>00743                 x2 = tmp;
<a name="l00744"></a>00744         }
<a name="l00745"></a>00745 
<a name="l00746"></a>00746         <span class="comment">/*</span>
<a name="l00747"></a>00747 <span class="comment">        * Swap y1, y2 if required </span>
<a name="l00748"></a>00748 <span class="comment">        */</span>
<a name="l00749"></a>00749         <span class="keywordflow">if</span> (y1 &gt; y2) {
<a name="l00750"></a>00750                 tmp = y1;
<a name="l00751"></a>00751                 y1 = y2;
<a name="l00752"></a>00752                 y2 = tmp;
<a name="l00753"></a>00753         }
<a name="l00754"></a>00754 
<a name="l00755"></a>00755         <span class="comment">/* </span>
<a name="l00756"></a>00756 <span class="comment">        * Create destination rect</span>
<a name="l00757"></a>00757 <span class="comment">        */</span>      
<a name="l00758"></a>00758         rect.x = x1;
<a name="l00759"></a>00759         rect.y = y1;
<a name="l00760"></a>00760         rect.w = x2 - x1 + 1;
<a name="l00761"></a>00761         rect.h = y2 - y1 + 1;
<a name="l00762"></a>00762         
<a name="l00763"></a>00763         <span class="comment">/*</span>
<a name="l00764"></a>00764 <span class="comment">        * Draw</span>
<a name="l00765"></a>00765 <span class="comment">        */</span>
<a name="l00766"></a>00766         result = 0;
<a name="l00767"></a>00767         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l00768"></a>00768         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a); 
<a name="l00769"></a>00769         result |= SDL_RenderFillRect(renderer, &amp;rect);
<a name="l00770"></a>00770         <span class="keywordflow">return</span> result;
<a name="l00771"></a>00771 }
<a name="l00772"></a>00772 
<a name="l00773"></a>00773 <span class="comment">/* ----- Line */</span>
<a name="l00774"></a>00774 
<a name="l00786"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac8efb30db084f16211f1f1dd648df618">00786</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac8efb30db084f16211f1f1dd648df618" title="Draw line with alpha blending using the currently set color.">line</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2)
<a name="l00787"></a>00787 {
<a name="l00788"></a>00788         <span class="comment">/*</span>
<a name="l00789"></a>00789 <span class="comment">        * Draw</span>
<a name="l00790"></a>00790 <span class="comment">        */</span>
<a name="l00791"></a>00791         <span class="keywordflow">return</span> SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
<a name="l00792"></a>00792 }
<a name="l00793"></a>00793 
<a name="l00806"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a84f917eb19ea41b586f1afa9eb4b552c">00806</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa84df90d36a8cb5a5afa61c50ffbfb71" title="Draw line with alpha blending.">lineColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
<a name="l00807"></a>00807 {
<a name="l00808"></a>00808         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l00809"></a>00809         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a82d13b4ab3057ebebb7706e451090712" title="Draw line with alpha blending.">lineRGBA</a>(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3]);
<a name="l00810"></a>00810 }
<a name="l00811"></a>00811 
<a name="l00827"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#ab56ec3fb82b59f2ab1d1877b6adb3b82">00827</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a82d13b4ab3057ebebb7706e451090712" title="Draw line with alpha blending.">lineRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l00828"></a>00828 {
<a name="l00829"></a>00829         <span class="comment">/*</span>
<a name="l00830"></a>00830 <span class="comment">        * Draw</span>
<a name="l00831"></a>00831 <span class="comment">        */</span>
<a name="l00832"></a>00832         <span class="keywordtype">int</span> result = 0;
<a name="l00833"></a>00833         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l00834"></a>00834         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a); 
<a name="l00835"></a>00835         result |= SDL_RenderDrawLine(renderer, x1, y1, x2, y2);
<a name="l00836"></a>00836         <span class="keywordflow">return</span> result;
<a name="l00837"></a>00837 }
<a name="l00838"></a>00838 
<a name="l00839"></a>00839 <span class="comment">/* ---- AA Line */</span>
<a name="l00840"></a>00840 
<a name="l00841"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a519bc2d4d753c51da1b956d6c200bff1">00841</a> <span class="preprocessor">#define AAlevels 256</span>
<a name="l00842"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a2e16571bedf7a97c6fc02d86b48994eb">00842</a> <span class="preprocessor"></span><span class="preprocessor">#define AAbits 8</span>
<a name="l00843"></a>00843 <span class="preprocessor"></span>
<a name="l00867"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab9e0ea0234edece7549a1606829a4563">00867</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab9e0ea0234edece7549a1606829a4563" title="Internal function to draw anti-aliased line with alpha blending and endpoint control.">_aalineRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a, <span class="keywordtype">int</span> draw_endpoint)
<a name="l00868"></a>00868 {
<a name="l00869"></a>00869         Sint32 xx0, yy0, xx1, yy1;
<a name="l00870"></a>00870         <span class="keywordtype">int</span> result;
<a name="l00871"></a>00871         Uint32 intshift, erracc, erradj;
<a name="l00872"></a>00872         Uint32 erracctmp, wgt, wgtcompmask;
<a name="l00873"></a>00873         <span class="keywordtype">int</span> dx, dy, tmp, xdir, y0p1, x0pxdir;
<a name="l00874"></a>00874 
<a name="l00875"></a>00875         <span class="comment">/*</span>
<a name="l00876"></a>00876 <span class="comment">        * Keep on working with 32bit numbers </span>
<a name="l00877"></a>00877 <span class="comment">        */</span>
<a name="l00878"></a>00878         xx0 = x1;
<a name="l00879"></a>00879         yy0 = y1;
<a name="l00880"></a>00880         xx1 = x2;
<a name="l00881"></a>00881         yy1 = y2;
<a name="l00882"></a>00882 
<a name="l00883"></a>00883         <span class="comment">/*</span>
<a name="l00884"></a>00884 <span class="comment">        * Reorder points to make dy positive </span>
<a name="l00885"></a>00885 <span class="comment">        */</span>
<a name="l00886"></a>00886         <span class="keywordflow">if</span> (yy0 &gt; yy1) {
<a name="l00887"></a>00887                 tmp = yy0;
<a name="l00888"></a>00888                 yy0 = yy1;
<a name="l00889"></a>00889                 yy1 = tmp;
<a name="l00890"></a>00890                 tmp = xx0;
<a name="l00891"></a>00891                 xx0 = xx1;
<a name="l00892"></a>00892                 xx1 = tmp;
<a name="l00893"></a>00893         }
<a name="l00894"></a>00894 
<a name="l00895"></a>00895         <span class="comment">/*</span>
<a name="l00896"></a>00896 <span class="comment">        * Calculate distance </span>
<a name="l00897"></a>00897 <span class="comment">        */</span>
<a name="l00898"></a>00898         dx = xx1 - xx0;
<a name="l00899"></a>00899         dy = yy1 - yy0;
<a name="l00900"></a>00900 
<a name="l00901"></a>00901         <span class="comment">/*</span>
<a name="l00902"></a>00902 <span class="comment">        * Adjust for negative dx and set xdir </span>
<a name="l00903"></a>00903 <span class="comment">        */</span>
<a name="l00904"></a>00904         <span class="keywordflow">if</span> (dx &gt;= 0) {
<a name="l00905"></a>00905                 xdir = 1;
<a name="l00906"></a>00906         } <span class="keywordflow">else</span> {
<a name="l00907"></a>00907                 xdir = -1;
<a name="l00908"></a>00908                 dx = (-dx);
<a name="l00909"></a>00909         }
<a name="l00910"></a>00910         
<a name="l00911"></a>00911         <span class="comment">/*</span>
<a name="l00912"></a>00912 <span class="comment">        * Check for special cases </span>
<a name="l00913"></a>00913 <span class="comment">        */</span>
<a name="l00914"></a>00914         <span class="keywordflow">if</span> (dx == 0) {
<a name="l00915"></a>00915                 <span class="comment">/*</span>
<a name="l00916"></a>00916 <span class="comment">                * Vertical line </span>
<a name="l00917"></a>00917 <span class="comment">                */</span>
<a name="l00918"></a>00918                 <span class="keywordflow">if</span> (draw_endpoint)
<a name="l00919"></a>00919                 {
<a name="l00920"></a>00920                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x1, y1, y2, r, g, b, a));
<a name="l00921"></a>00921                 } <span class="keywordflow">else</span> {
<a name="l00922"></a>00922                         <span class="keywordflow">if</span> (dy &gt; 0) {
<a name="l00923"></a>00923                                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x1, yy0, yy0+dy, r, g, b, a));
<a name="l00924"></a>00924                         } <span class="keywordflow">else</span> {
<a name="l00925"></a>00925                                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x1, y1, r, g, b, a));
<a name="l00926"></a>00926                         }
<a name="l00927"></a>00927                 }
<a name="l00928"></a>00928         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dy == 0) {
<a name="l00929"></a>00929                 <span class="comment">/*</span>
<a name="l00930"></a>00930 <span class="comment">                * Horizontal line </span>
<a name="l00931"></a>00931 <span class="comment">                */</span>
<a name="l00932"></a>00932                 <span class="keywordflow">if</span> (draw_endpoint)
<a name="l00933"></a>00933                 {
<a name="l00934"></a>00934                         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x1, x2, y1, r, g, b, a));
<a name="l00935"></a>00935                 } <span class="keywordflow">else</span> {
<a name="l00936"></a>00936                         <span class="keywordflow">if</span> (dx &gt; 0) {
<a name="l00937"></a>00937                                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, xx0, xx0+dx, y1, r, g, b, a));
<a name="l00938"></a>00938                         } <span class="keywordflow">else</span> {
<a name="l00939"></a>00939                                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x1, y1, r, g, b, a));
<a name="l00940"></a>00940                         }
<a name="l00941"></a>00941                 }
<a name="l00942"></a>00942         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((dx == dy) &amp;&amp; (draw_endpoint)) {
<a name="l00943"></a>00943                 <span class="comment">/*</span>
<a name="l00944"></a>00944 <span class="comment">                * Diagonal line (with endpoint)</span>
<a name="l00945"></a>00945 <span class="comment">                */</span>
<a name="l00946"></a>00946                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a82d13b4ab3057ebebb7706e451090712" title="Draw line with alpha blending.">lineRGBA</a>(renderer, x1, y1, x2, y2,  r, g, b, a));
<a name="l00947"></a>00947         }
<a name="l00948"></a>00948 
<a name="l00949"></a>00949 
<a name="l00950"></a>00950         <span class="comment">/*</span>
<a name="l00951"></a>00951 <span class="comment">        * Line is not horizontal, vertical or diagonal (with endpoint)</span>
<a name="l00952"></a>00952 <span class="comment">        */</span>
<a name="l00953"></a>00953         result = 0;
<a name="l00954"></a>00954 
<a name="l00955"></a>00955         <span class="comment">/*</span>
<a name="l00956"></a>00956 <span class="comment">        * Zero accumulator </span>
<a name="l00957"></a>00957 <span class="comment">        */</span>
<a name="l00958"></a>00958         erracc = 0;
<a name="l00959"></a>00959 
<a name="l00960"></a>00960         <span class="comment">/*</span>
<a name="l00961"></a>00961 <span class="comment">        * # of bits by which to shift erracc to get intensity level </span>
<a name="l00962"></a>00962 <span class="comment">        */</span>
<a name="l00963"></a>00963         intshift = 32 - <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a2e16571bedf7a97c6fc02d86b48994eb">AAbits</a>;
<a name="l00964"></a>00964 
<a name="l00965"></a>00965         <span class="comment">/*</span>
<a name="l00966"></a>00966 <span class="comment">        * Mask used to flip all bits in an intensity weighting </span>
<a name="l00967"></a>00967 <span class="comment">        */</span>
<a name="l00968"></a>00968         wgtcompmask = <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a519bc2d4d753c51da1b956d6c200bff1">AAlevels</a> - 1;
<a name="l00969"></a>00969 
<a name="l00970"></a>00970         <span class="comment">/*</span>
<a name="l00971"></a>00971 <span class="comment">        * Draw the initial pixel in the foreground color </span>
<a name="l00972"></a>00972 <span class="comment">        */</span>
<a name="l00973"></a>00973         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x1, y1, r, g, b, a);
<a name="l00974"></a>00974 
<a name="l00975"></a>00975         <span class="comment">/*</span>
<a name="l00976"></a>00976 <span class="comment">        * x-major or y-major? </span>
<a name="l00977"></a>00977 <span class="comment">        */</span>
<a name="l00978"></a>00978         <span class="keywordflow">if</span> (dy &gt; dx) {
<a name="l00979"></a>00979 
<a name="l00980"></a>00980                 <span class="comment">/*</span>
<a name="l00981"></a>00981 <span class="comment">                * y-major.  Calculate 16-bit fixed point fractional part of a pixel that</span>
<a name="l00982"></a>00982 <span class="comment">                * X advances every time Y advances 1 pixel, truncating the result so that</span>
<a name="l00983"></a>00983 <span class="comment">                * we won&#39;t overrun the endpoint along the X axis </span>
<a name="l00984"></a>00984 <span class="comment">                */</span>
<a name="l00985"></a>00985                 <span class="comment">/*</span>
<a name="l00986"></a>00986 <span class="comment">                * Not-so-portable version: erradj = ((Uint64)dx &lt;&lt; 32) / (Uint64)dy; </span>
<a name="l00987"></a>00987 <span class="comment">                */</span>
<a name="l00988"></a>00988                 erradj = ((dx &lt;&lt; 16) / dy) &lt;&lt; 16;
<a name="l00989"></a>00989 
<a name="l00990"></a>00990                 <span class="comment">/*</span>
<a name="l00991"></a>00991 <span class="comment">                * draw all pixels other than the first and last </span>
<a name="l00992"></a>00992 <span class="comment">                */</span>
<a name="l00993"></a>00993                 x0pxdir = xx0 + xdir;
<a name="l00994"></a>00994                 <span class="keywordflow">while</span> (--dy) {
<a name="l00995"></a>00995                         erracctmp = erracc;
<a name="l00996"></a>00996                         erracc += erradj;
<a name="l00997"></a>00997                         <span class="keywordflow">if</span> (erracc &lt;= erracctmp) {
<a name="l00998"></a>00998                                 <span class="comment">/*</span>
<a name="l00999"></a>00999 <span class="comment">                                * rollover in error accumulator, x coord advances </span>
<a name="l01000"></a>01000 <span class="comment">                                */</span>
<a name="l01001"></a>01001                                 xx0 = x0pxdir;
<a name="l01002"></a>01002                                 x0pxdir += xdir;
<a name="l01003"></a>01003                         }
<a name="l01004"></a>01004                         yy0++;          <span class="comment">/* y-major so always advance Y */</span>
<a name="l01005"></a>01005 
<a name="l01006"></a>01006                         <span class="comment">/*</span>
<a name="l01007"></a>01007 <span class="comment">                        * the AAbits most significant bits of erracc give us the intensity</span>
<a name="l01008"></a>01008 <span class="comment">                        * weighting for this pixel, and the complement of the weighting for</span>
<a name="l01009"></a>01009 <span class="comment">                        * the paired pixel. </span>
<a name="l01010"></a>01010 <span class="comment">                        */</span>
<a name="l01011"></a>01011                         wgt = (erracc &gt;&gt; intshift) &amp; 255;
<a name="l01012"></a>01012                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a> (renderer, xx0, yy0, r, g, b, a, 255 - wgt);
<a name="l01013"></a>01013                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a> (renderer, x0pxdir, yy0, r, g, b, a, wgt);
<a name="l01014"></a>01014                 }
<a name="l01015"></a>01015 
<a name="l01016"></a>01016         } <span class="keywordflow">else</span> {
<a name="l01017"></a>01017 
<a name="l01018"></a>01018                 <span class="comment">/*</span>
<a name="l01019"></a>01019 <span class="comment">                * x-major line.  Calculate 16-bit fixed-point fractional part of a pixel</span>
<a name="l01020"></a>01020 <span class="comment">                * that Y advances each time X advances 1 pixel, truncating the result so</span>
<a name="l01021"></a>01021 <span class="comment">                * that we won&#39;t overrun the endpoint along the X axis. </span>
<a name="l01022"></a>01022 <span class="comment">                */</span>
<a name="l01023"></a>01023                 <span class="comment">/*</span>
<a name="l01024"></a>01024 <span class="comment">                * Not-so-portable version: erradj = ((Uint64)dy &lt;&lt; 32) / (Uint64)dx; </span>
<a name="l01025"></a>01025 <span class="comment">                */</span>
<a name="l01026"></a>01026                 erradj = ((dy &lt;&lt; 16) / dx) &lt;&lt; 16;
<a name="l01027"></a>01027 
<a name="l01028"></a>01028                 <span class="comment">/*</span>
<a name="l01029"></a>01029 <span class="comment">                * draw all pixels other than the first and last </span>
<a name="l01030"></a>01030 <span class="comment">                */</span>
<a name="l01031"></a>01031                 y0p1 = yy0 + 1;
<a name="l01032"></a>01032                 <span class="keywordflow">while</span> (--dx) {
<a name="l01033"></a>01033 
<a name="l01034"></a>01034                         erracctmp = erracc;
<a name="l01035"></a>01035                         erracc += erradj;
<a name="l01036"></a>01036                         <span class="keywordflow">if</span> (erracc &lt;= erracctmp) {
<a name="l01037"></a>01037                                 <span class="comment">/*</span>
<a name="l01038"></a>01038 <span class="comment">                                * Accumulator turned over, advance y </span>
<a name="l01039"></a>01039 <span class="comment">                                */</span>
<a name="l01040"></a>01040                                 yy0 = y0p1;
<a name="l01041"></a>01041                                 y0p1++;
<a name="l01042"></a>01042                         }
<a name="l01043"></a>01043                         xx0 += xdir;    <span class="comment">/* x-major so always advance X */</span>
<a name="l01044"></a>01044                         <span class="comment">/*</span>
<a name="l01045"></a>01045 <span class="comment">                        * the AAbits most significant bits of erracc give us the intensity</span>
<a name="l01046"></a>01046 <span class="comment">                        * weighting for this pixel, and the complement of the weighting for</span>
<a name="l01047"></a>01047 <span class="comment">                        * the paired pixel. </span>
<a name="l01048"></a>01048 <span class="comment">                        */</span>
<a name="l01049"></a>01049                         wgt = (erracc &gt;&gt; intshift) &amp; 255;
<a name="l01050"></a>01050                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a> (renderer, xx0, yy0, r, g, b, a, 255 - wgt);
<a name="l01051"></a>01051                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a> (renderer, xx0, y0p1, r, g, b, a, wgt);
<a name="l01052"></a>01052                 }
<a name="l01053"></a>01053         }
<a name="l01054"></a>01054 
<a name="l01055"></a>01055         <span class="comment">/*</span>
<a name="l01056"></a>01056 <span class="comment">        * Do we have to draw the endpoint </span>
<a name="l01057"></a>01057 <span class="comment">        */</span>
<a name="l01058"></a>01058         <span class="keywordflow">if</span> (draw_endpoint) {
<a name="l01059"></a>01059                 <span class="comment">/*</span>
<a name="l01060"></a>01060 <span class="comment">                * Draw final pixel, always exactly intersected by the line and doesn&#39;t</span>
<a name="l01061"></a>01061 <span class="comment">                * need to be weighted. </span>
<a name="l01062"></a>01062 <span class="comment">                */</span>
<a name="l01063"></a>01063                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a> (renderer, x2, y2, r, g, b, a);
<a name="l01064"></a>01064         }
<a name="l01065"></a>01065 
<a name="l01066"></a>01066         <span class="keywordflow">return</span> (result);
<a name="l01067"></a>01067 }
<a name="l01068"></a>01068 
<a name="l01081"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a86ab777f53655a509a3ac3c008941920">01081</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1cf2a63c9f995a7fb380715b14ccd281" title="Draw anti-aliased line with alpha blending.">aalineColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color)
<a name="l01082"></a>01082 {
<a name="l01083"></a>01083         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l01084"></a>01084         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab9e0ea0234edece7549a1606829a4563" title="Internal function to draw anti-aliased line with alpha blending and endpoint control.">_aalineRGBA</a>(renderer, x1, y1, x2, y2, c[0], c[1], c[2], c[3], 1);
<a name="l01085"></a>01085 }
<a name="l01086"></a>01086 
<a name="l01102"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#ad7074bc1af414cea003712621b1c7d86">01102</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a076261278dad9921ee72411f3f3fbacc" title="Draw anti-aliased line with alpha blending.">aalineRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l01103"></a>01103 {
<a name="l01104"></a>01104         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab9e0ea0234edece7549a1606829a4563" title="Internal function to draw anti-aliased line with alpha blending and endpoint control.">_aalineRGBA</a>(renderer, x1, y1, x2, y2, r, g, b, a, 1);
<a name="l01105"></a>01105 }
<a name="l01106"></a>01106 
<a name="l01107"></a>01107 <span class="comment">/* ----- Circle */</span>
<a name="l01108"></a>01108 
<a name="l01120"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#af68b52c59d2a7a6b7cc817158941ac54">01120</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a52bc17933a4cd0bbf8e8b2bb4d791765" title="Draw circle with blending.">circleColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
<a name="l01121"></a>01121 {
<a name="l01122"></a>01122         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l01123"></a>01123         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a15eed0329a3aa0642cc0b743262cacb3" title="Draw ellipse with blending.">ellipseRGBA</a>(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
<a name="l01124"></a>01124 }
<a name="l01125"></a>01125 
<a name="l01140"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a1daab46976bf585477be1cfcef2fe1ad">01140</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a5c31cfec612a817f2efb01a65001961e" title="Draw circle with blending.">circleRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l01141"></a>01141 {
<a name="l01142"></a>01142         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a15eed0329a3aa0642cc0b743262cacb3" title="Draw ellipse with blending.">ellipseRGBA</a>(renderer, x, y, rad, rad, r, g, b, a);
<a name="l01143"></a>01143 }
<a name="l01144"></a>01144 
<a name="l01145"></a>01145 <span class="comment">/* ----- Arc */</span>
<a name="l01146"></a>01146 
<a name="l01160"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a493fe37b39da582668431ab7e1e3dbf0">01160</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a4b0a963ec00fbf6101ae28834aaacc6e" title="Arc with blending.">arcColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
<a name="l01161"></a>01161 {
<a name="l01162"></a>01162         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l01163"></a>01163         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a0445c87dd018fe7f26c0343bb1545cc5" title="Arc with blending.">arcRGBA</a>(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3]);
<a name="l01164"></a>01164 }
<a name="l01165"></a>01165 
<a name="l01182"></a>01182 <span class="comment">/* TODO: rewrite algorithm; arc endpoints are not always drawn */</span>
<a name="l01183"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#acf0091a17501f375f2b55032134b3017">01183</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a0445c87dd018fe7f26c0343bb1545cc5" title="Arc with blending.">arcRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l01184"></a>01184 {
<a name="l01185"></a>01185         <span class="keywordtype">int</span> result;
<a name="l01186"></a>01186         Sint16 cx = 0;
<a name="l01187"></a>01187         Sint16 cy = rad;
<a name="l01188"></a>01188         Sint16 df = 1 - rad;
<a name="l01189"></a>01189         Sint16 d_e = 3;
<a name="l01190"></a>01190         Sint16 d_se = -2 * rad + 5;
<a name="l01191"></a>01191         Sint16 xpcx, xmcx, xpcy, xmcy;
<a name="l01192"></a>01192         Sint16 ypcy, ymcy, ypcx, ymcx;
<a name="l01193"></a>01193         Uint8 drawoct;
<a name="l01194"></a>01194         <span class="keywordtype">int</span> startoct, endoct, oct, stopval_start = 0, stopval_end = 0;
<a name="l01195"></a>01195         <span class="keywordtype">double</span> dstart, dend, temp = 0.;
<a name="l01196"></a>01196 
<a name="l01197"></a>01197         <span class="comment">/*</span>
<a name="l01198"></a>01198 <span class="comment">        * Sanity check radius </span>
<a name="l01199"></a>01199 <span class="comment">        */</span>
<a name="l01200"></a>01200         <span class="keywordflow">if</span> (rad &lt; 0) {
<a name="l01201"></a>01201                 <span class="keywordflow">return</span> (-1);
<a name="l01202"></a>01202         }
<a name="l01203"></a>01203 
<a name="l01204"></a>01204         <span class="comment">/*</span>
<a name="l01205"></a>01205 <span class="comment">        * Special case for rad=0 - draw a point </span>
<a name="l01206"></a>01206 <span class="comment">        */</span>
<a name="l01207"></a>01207         <span class="keywordflow">if</span> (rad == 0) {
<a name="l01208"></a>01208                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x, y, r, g, b, a));
<a name="l01209"></a>01209         }
<a name="l01210"></a>01210 
<a name="l01211"></a>01211         <span class="comment">// Octant labelling</span>
<a name="l01212"></a>01212         <span class="comment">//      </span>
<a name="l01213"></a>01213         <span class="comment">//  \ 5 | 6 /</span>
<a name="l01214"></a>01214         <span class="comment">//   \  |  /</span>
<a name="l01215"></a>01215         <span class="comment">//  4 \ | / 7</span>
<a name="l01216"></a>01216         <span class="comment">//     \|/</span>
<a name="l01217"></a>01217         <span class="comment">//------+------ +x</span>
<a name="l01218"></a>01218         <span class="comment">//     /|\</span>
<a name="l01219"></a>01219 <span class="comment">        //  3 / | \ 0</span>
<a name="l01220"></a>01220         <span class="comment">//   /  |  \</span>
<a name="l01221"></a>01221 <span class="comment">        //  / 2 | 1 \</span>
<a name="l01222"></a>01222 <span class="comment">        //      +y</span>
<a name="l01223"></a>01223 
<a name="l01224"></a>01224         <span class="comment">// Initially reset bitmask to 0x00000000</span>
<a name="l01225"></a>01225         <span class="comment">// the set whether or not to keep drawing a given octant.</span>
<a name="l01226"></a>01226         <span class="comment">// For example: 0x00111100 means we&#39;re drawing in octants 2-5</span>
<a name="l01227"></a>01227         drawoct = 0; 
<a name="l01228"></a>01228 
<a name="l01229"></a>01229         <span class="comment">/*</span>
<a name="l01230"></a>01230 <span class="comment">        * Fixup angles</span>
<a name="l01231"></a>01231 <span class="comment">        */</span>
<a name="l01232"></a>01232         start %= 360;
<a name="l01233"></a>01233         end %= 360;
<a name="l01234"></a>01234         <span class="comment">// 0 &lt;= start &amp; end &lt; 360; note that sometimes start &gt; end - if so, arc goes back through 0.</span>
<a name="l01235"></a>01235         <span class="keywordflow">while</span> (start &lt; 0) start += 360;
<a name="l01236"></a>01236         <span class="keywordflow">while</span> (end &lt; 0) end += 360;
<a name="l01237"></a>01237         start %= 360;
<a name="l01238"></a>01238         end %= 360;
<a name="l01239"></a>01239 
<a name="l01240"></a>01240         <span class="comment">// now, we find which octants we&#39;re drawing in.</span>
<a name="l01241"></a>01241         startoct = start / 45;
<a name="l01242"></a>01242         endoct = end / 45;
<a name="l01243"></a>01243         oct = startoct - 1; <span class="comment">// we increment as first step in loop</span>
<a name="l01244"></a>01244 
<a name="l01245"></a>01245         <span class="comment">// stopval_start, stopval_end; </span>
<a name="l01246"></a>01246         <span class="comment">// what values of cx to stop at.</span>
<a name="l01247"></a>01247         <span class="keywordflow">do</span> {
<a name="l01248"></a>01248                 oct = (oct + 1) % 8;
<a name="l01249"></a>01249 
<a name="l01250"></a>01250                 <span class="keywordflow">if</span> (oct == startoct) {
<a name="l01251"></a>01251                         <span class="comment">// need to compute stopval_start for this octant.  Look at picture above if this is unclear</span>
<a name="l01252"></a>01252                         dstart = (double)start;
<a name="l01253"></a>01253                         <span class="keywordflow">switch</span> (oct) 
<a name="l01254"></a>01254                         {
<a name="l01255"></a>01255                         <span class="keywordflow">case</span> 0:
<a name="l01256"></a>01256                         <span class="keywordflow">case</span> 3:
<a name="l01257"></a>01257                                 temp = sin(dstart * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180.);
<a name="l01258"></a>01258                                 <span class="keywordflow">break</span>;
<a name="l01259"></a>01259                         <span class="keywordflow">case</span> 1:
<a name="l01260"></a>01260                         <span class="keywordflow">case</span> 6:
<a name="l01261"></a>01261                                 temp = cos(dstart * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180.);
<a name="l01262"></a>01262                                 <span class="keywordflow">break</span>;
<a name="l01263"></a>01263                         <span class="keywordflow">case</span> 2:
<a name="l01264"></a>01264                         <span class="keywordflow">case</span> 5:
<a name="l01265"></a>01265                                 temp = -cos(dstart * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180.);
<a name="l01266"></a>01266                                 <span class="keywordflow">break</span>;
<a name="l01267"></a>01267                         <span class="keywordflow">case</span> 4:
<a name="l01268"></a>01268                         <span class="keywordflow">case</span> 7:
<a name="l01269"></a>01269                                 temp = -sin(dstart * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180.);
<a name="l01270"></a>01270                                 <span class="keywordflow">break</span>;
<a name="l01271"></a>01271                         }
<a name="l01272"></a>01272                         temp *= rad;
<a name="l01273"></a>01273                         stopval_start = (int)temp; <span class="comment">// always round down</span>
<a name="l01274"></a>01274 
<a name="l01275"></a>01275                         <span class="comment">// This isn&#39;t arbitrary, but requires graph paper to explain well.</span>
<a name="l01276"></a>01276                         <span class="comment">// The basic idea is that we&#39;re always changing drawoct after we draw, so we</span>
<a name="l01277"></a>01277                         <span class="comment">// stop immediately after we render the last sensible pixel at x = ((int)temp).</span>
<a name="l01278"></a>01278 
<a name="l01279"></a>01279                         <span class="comment">// and whether to draw in this octant initially</span>
<a name="l01280"></a>01280                         <span class="keywordflow">if</span> (oct % 2) drawoct |= (1 &lt;&lt; oct); <span class="comment">// this is basically like saying drawoct[oct] = true, if drawoct were a bool array</span>
<a name="l01281"></a>01281                         <span class="keywordflow">else</span>             drawoct &amp;= 255 - (1 &lt;&lt; oct); <span class="comment">// this is basically like saying drawoct[oct] = false</span>
<a name="l01282"></a>01282                 }
<a name="l01283"></a>01283                 <span class="keywordflow">if</span> (oct == endoct) {
<a name="l01284"></a>01284                         <span class="comment">// need to compute stopval_end for this octant</span>
<a name="l01285"></a>01285                         dend = (double)end;
<a name="l01286"></a>01286                         <span class="keywordflow">switch</span> (oct)
<a name="l01287"></a>01287                         {
<a name="l01288"></a>01288                         <span class="keywordflow">case</span> 0:
<a name="l01289"></a>01289                         <span class="keywordflow">case</span> 3:
<a name="l01290"></a>01290                                 temp = sin(dend * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180);
<a name="l01291"></a>01291                                 <span class="keywordflow">break</span>;
<a name="l01292"></a>01292                         <span class="keywordflow">case</span> 1:
<a name="l01293"></a>01293                         <span class="keywordflow">case</span> 6:
<a name="l01294"></a>01294                                 temp = cos(dend * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180);
<a name="l01295"></a>01295                                 <span class="keywordflow">break</span>;
<a name="l01296"></a>01296                         <span class="keywordflow">case</span> 2:
<a name="l01297"></a>01297                         <span class="keywordflow">case</span> 5:
<a name="l01298"></a>01298                                 temp = -cos(dend * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180);
<a name="l01299"></a>01299                                 <span class="keywordflow">break</span>;
<a name="l01300"></a>01300                         <span class="keywordflow">case</span> 4:
<a name="l01301"></a>01301                         <span class="keywordflow">case</span> 7:
<a name="l01302"></a>01302                                 temp = -sin(dend * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 180);
<a name="l01303"></a>01303                                 <span class="keywordflow">break</span>;
<a name="l01304"></a>01304                         }
<a name="l01305"></a>01305                         temp *= rad;
<a name="l01306"></a>01306                         stopval_end = (int)temp;
<a name="l01307"></a>01307 
<a name="l01308"></a>01308                         <span class="comment">// and whether to draw in this octant initially</span>
<a name="l01309"></a>01309                         <span class="keywordflow">if</span> (startoct == endoct) {
<a name="l01310"></a>01310                                 <span class="comment">// note:      we start drawing, stop, then start again in this case</span>
<a name="l01311"></a>01311                                 <span class="comment">// otherwise: we only draw in this octant, so initialize it to false, it will get set back to true</span>
<a name="l01312"></a>01312                                 <span class="keywordflow">if</span> (start &gt; end) {
<a name="l01313"></a>01313                                         <span class="comment">// unfortunately, if we&#39;re in the same octant and need to draw over the whole circle, </span>
<a name="l01314"></a>01314                                         <span class="comment">// we need to set the rest to true, because the while loop will end at the bottom.</span>
<a name="l01315"></a>01315                                         drawoct = 255;
<a name="l01316"></a>01316                                 } <span class="keywordflow">else</span> {
<a name="l01317"></a>01317                                         drawoct &amp;= 255 - (1 &lt;&lt; oct);
<a name="l01318"></a>01318                                 }
<a name="l01319"></a>01319                         } 
<a name="l01320"></a>01320                         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (oct % 2) drawoct &amp;= 255 - (1 &lt;&lt; oct);
<a name="l01321"></a>01321                         <span class="keywordflow">else</span>                      drawoct |= (1 &lt;&lt; oct);
<a name="l01322"></a>01322                 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (oct != startoct) { <span class="comment">// already verified that it&#39;s != endoct</span>
<a name="l01323"></a>01323                         drawoct |= (1 &lt;&lt; oct); <span class="comment">// draw this entire segment</span>
<a name="l01324"></a>01324                 }
<a name="l01325"></a>01325         } <span class="keywordflow">while</span> (oct != endoct);
<a name="l01326"></a>01326 
<a name="l01327"></a>01327         <span class="comment">// so now we have what octants to draw and when to draw them. all that&#39;s left is the actual raster code.</span>
<a name="l01328"></a>01328 
<a name="l01329"></a>01329         <span class="comment">/*</span>
<a name="l01330"></a>01330 <span class="comment">        * Set color </span>
<a name="l01331"></a>01331 <span class="comment">        */</span>
<a name="l01332"></a>01332         result = 0;
<a name="l01333"></a>01333         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l01334"></a>01334         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l01335"></a>01335 
<a name="l01336"></a>01336         <span class="comment">/*</span>
<a name="l01337"></a>01337 <span class="comment">        * Draw arc </span>
<a name="l01338"></a>01338 <span class="comment">        */</span>
<a name="l01339"></a>01339         <span class="keywordflow">do</span> {
<a name="l01340"></a>01340                 ypcy = y + cy;
<a name="l01341"></a>01341                 ymcy = y - cy;
<a name="l01342"></a>01342                 <span class="keywordflow">if</span> (cx &gt; 0) {
<a name="l01343"></a>01343                         xpcx = x + cx;
<a name="l01344"></a>01344                         xmcx = x - cx;
<a name="l01345"></a>01345 
<a name="l01346"></a>01346                         <span class="comment">// always check if we&#39;re drawing a certain octant before adding a pixel to that octant.</span>
<a name="l01347"></a>01347                         <span class="keywordflow">if</span> (drawoct &amp; 4)  result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmcx, ypcy);
<a name="l01348"></a>01348                         <span class="keywordflow">if</span> (drawoct &amp; 2)  result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpcx, ypcy);
<a name="l01349"></a>01349                         <span class="keywordflow">if</span> (drawoct &amp; 32) result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmcx, ymcy);
<a name="l01350"></a>01350                         <span class="keywordflow">if</span> (drawoct &amp; 64) result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpcx, ymcy);
<a name="l01351"></a>01351                 } <span class="keywordflow">else</span> {
<a name="l01352"></a>01352                         <span class="keywordflow">if</span> (drawoct &amp; 96) result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, x, ymcy);
<a name="l01353"></a>01353                         <span class="keywordflow">if</span> (drawoct &amp; 6)  result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, x, ypcy);
<a name="l01354"></a>01354                 }
<a name="l01355"></a>01355 
<a name="l01356"></a>01356                 xpcy = x + cy;
<a name="l01357"></a>01357                 xmcy = x - cy;
<a name="l01358"></a>01358                 <span class="keywordflow">if</span> (cx &gt; 0 &amp;&amp; cx != cy) {
<a name="l01359"></a>01359                         ypcx = y + cx;
<a name="l01360"></a>01360                         ymcx = y - cx;
<a name="l01361"></a>01361                         <span class="keywordflow">if</span> (drawoct &amp; 8)   result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmcy, ypcx);
<a name="l01362"></a>01362                         <span class="keywordflow">if</span> (drawoct &amp; 1)   result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpcy, ypcx);
<a name="l01363"></a>01363                         <span class="keywordflow">if</span> (drawoct &amp; 16)  result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmcy, ymcx);
<a name="l01364"></a>01364                         <span class="keywordflow">if</span> (drawoct &amp; 128) result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpcy, ymcx);
<a name="l01365"></a>01365                 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cx == 0) {
<a name="l01366"></a>01366                         <span class="keywordflow">if</span> (drawoct &amp; 24)  result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmcy, y);
<a name="l01367"></a>01367                         <span class="keywordflow">if</span> (drawoct &amp; 129) result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpcy, y);
<a name="l01368"></a>01368                 }
<a name="l01369"></a>01369 
<a name="l01370"></a>01370                 <span class="comment">/*</span>
<a name="l01371"></a>01371 <span class="comment">                * Update whether we&#39;re drawing an octant</span>
<a name="l01372"></a>01372 <span class="comment">                */</span>
<a name="l01373"></a>01373                 <span class="keywordflow">if</span> (stopval_start == cx) {
<a name="l01374"></a>01374                         <span class="comment">// works like an on-off switch.  </span>
<a name="l01375"></a>01375                         <span class="comment">// This is just in case start &amp; end are in the same octant.</span>
<a name="l01376"></a>01376                         <span class="keywordflow">if</span> (drawoct &amp; (1 &lt;&lt; startoct)) drawoct &amp;= 255 - (1 &lt;&lt; startoct);                
<a name="l01377"></a>01377                         <span class="keywordflow">else</span>                                               drawoct |= (1 &lt;&lt; startoct);
<a name="l01378"></a>01378                 }
<a name="l01379"></a>01379                 <span class="keywordflow">if</span> (stopval_end == cx) {
<a name="l01380"></a>01380                         <span class="keywordflow">if</span> (drawoct &amp; (1 &lt;&lt; endoct)) drawoct &amp;= 255 - (1 &lt;&lt; endoct);
<a name="l01381"></a>01381                         <span class="keywordflow">else</span>                                             drawoct |= (1 &lt;&lt; endoct);
<a name="l01382"></a>01382                 }
<a name="l01383"></a>01383 
<a name="l01384"></a>01384                 <span class="comment">/*</span>
<a name="l01385"></a>01385 <span class="comment">                * Update pixels</span>
<a name="l01386"></a>01386 <span class="comment">                */</span>
<a name="l01387"></a>01387                 <span class="keywordflow">if</span> (df &lt; 0) {
<a name="l01388"></a>01388                         df += d_e;
<a name="l01389"></a>01389                         d_e += 2;
<a name="l01390"></a>01390                         d_se += 2;
<a name="l01391"></a>01391                 } <span class="keywordflow">else</span> {
<a name="l01392"></a>01392                         df += d_se;
<a name="l01393"></a>01393                         d_e += 2;
<a name="l01394"></a>01394                         d_se += 4;
<a name="l01395"></a>01395                         cy--;
<a name="l01396"></a>01396                 }
<a name="l01397"></a>01397                 cx++;
<a name="l01398"></a>01398         } <span class="keywordflow">while</span> (cx &lt;= cy);
<a name="l01399"></a>01399 
<a name="l01400"></a>01400         <span class="keywordflow">return</span> (result);
<a name="l01401"></a>01401 }
<a name="l01402"></a>01402 
<a name="l01403"></a>01403 <span class="comment">/* ----- AA Circle */</span>
<a name="l01404"></a>01404 
<a name="l01416"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a46b037505b91133ae3bd18556092a632">01416</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae36b22e71441985957ab7ec46724f64a" title="Draw anti-aliased circle with blending.">aacircleColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
<a name="l01417"></a>01417 {
<a name="l01418"></a>01418         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l01419"></a>01419         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac5714e2b6a067371ae94ee47b834e36a" title="Draw anti-aliased ellipse with blending.">aaellipseRGBA</a>(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
<a name="l01420"></a>01420 }
<a name="l01421"></a>01421 
<a name="l01436"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#aa0b0f764826715353e9ca0fe937d0f0f">01436</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a77939c678e5948e97d231618893ec4a6" title="Draw anti-aliased circle with blending.">aacircleRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l01437"></a>01437 {
<a name="l01438"></a>01438         <span class="comment">/*</span>
<a name="l01439"></a>01439 <span class="comment">        * Draw </span>
<a name="l01440"></a>01440 <span class="comment">        */</span>
<a name="l01441"></a>01441         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac5714e2b6a067371ae94ee47b834e36a" title="Draw anti-aliased ellipse with blending.">aaellipseRGBA</a>(renderer, x, y, rad, rad, r, g, b, a);
<a name="l01442"></a>01442 }
<a name="l01443"></a>01443 
<a name="l01444"></a>01444 <span class="comment">/* ----- Filled Circle */</span>
<a name="l01445"></a>01445 
<a name="l01457"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#ab973fd9868527fb13078c356d4a9c6f7">01457</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac517d328d433a563793f3d51ed4e3080" title="Draw filled circle with blending.">filledCircleColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint32 color)
<a name="l01458"></a>01458 {
<a name="l01459"></a>01459         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l01460"></a>01460         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a40aad9eb1dc3000251712c1e16dacd26" title="Draw filled ellipse with blending.">filledEllipseRGBA</a>(renderer, x, y, rad, rad, c[0], c[1], c[2], c[3]);
<a name="l01461"></a>01461 }
<a name="l01462"></a>01462 
<a name="l01477"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a666bd764e2fe962656e5829d0aad5ba6">01477</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a84a0671e43b049dd1f43ff5b1b031c21" title="Draw filled circle with blending.">filledCircleRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l01478"></a>01478 {
<a name="l01479"></a>01479         <span class="keywordtype">int</span> result;
<a name="l01480"></a>01480         Sint16 cx = 0;
<a name="l01481"></a>01481         Sint16 cy = rad;
<a name="l01482"></a>01482         Sint16 ocx = (Sint16) 0xffff;
<a name="l01483"></a>01483         Sint16 ocy = (Sint16) 0xffff;
<a name="l01484"></a>01484         Sint16 df = 1 - rad;
<a name="l01485"></a>01485         Sint16 d_e = 3;
<a name="l01486"></a>01486         Sint16 d_se = -2 * rad + 5;
<a name="l01487"></a>01487         Sint16 xpcx, xmcx, xpcy, xmcy;
<a name="l01488"></a>01488         Sint16 ypcy, ymcy, ypcx, ymcx;
<a name="l01489"></a>01489 
<a name="l01490"></a>01490         <span class="comment">/*</span>
<a name="l01491"></a>01491 <span class="comment">        * Sanity check radius </span>
<a name="l01492"></a>01492 <span class="comment">        */</span>
<a name="l01493"></a>01493         <span class="keywordflow">if</span> (rad &lt; 0) {
<a name="l01494"></a>01494                 <span class="keywordflow">return</span> (-1);
<a name="l01495"></a>01495         }
<a name="l01496"></a>01496 
<a name="l01497"></a>01497         <span class="comment">/*</span>
<a name="l01498"></a>01498 <span class="comment">        * Special case for rad=0 - draw a point </span>
<a name="l01499"></a>01499 <span class="comment">        */</span>
<a name="l01500"></a>01500         <span class="keywordflow">if</span> (rad == 0) {
<a name="l01501"></a>01501                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x, y, r, g, b, a));
<a name="l01502"></a>01502         }
<a name="l01503"></a>01503 
<a name="l01504"></a>01504         <span class="comment">/*</span>
<a name="l01505"></a>01505 <span class="comment">        * Set color</span>
<a name="l01506"></a>01506 <span class="comment">        */</span>
<a name="l01507"></a>01507         result = 0;
<a name="l01508"></a>01508         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l01509"></a>01509         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l01510"></a>01510 
<a name="l01511"></a>01511         <span class="comment">/*</span>
<a name="l01512"></a>01512 <span class="comment">        * Draw </span>
<a name="l01513"></a>01513 <span class="comment">        */</span>
<a name="l01514"></a>01514         <span class="keywordflow">do</span> {
<a name="l01515"></a>01515                 xpcx = x + cx;
<a name="l01516"></a>01516                 xmcx = x - cx;
<a name="l01517"></a>01517                 xpcy = x + cy;
<a name="l01518"></a>01518                 xmcy = x - cy;
<a name="l01519"></a>01519                 <span class="keywordflow">if</span> (ocy != cy) {
<a name="l01520"></a>01520                         <span class="keywordflow">if</span> (cy &gt; 0) {
<a name="l01521"></a>01521                                 ypcy = y + cy;
<a name="l01522"></a>01522                                 ymcy = y - cy;
<a name="l01523"></a>01523                                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcx, xpcx, ypcy);
<a name="l01524"></a>01524                                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcx, xpcx, ymcy);
<a name="l01525"></a>01525                         } <span class="keywordflow">else</span> {
<a name="l01526"></a>01526                                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcx, xpcx, y);
<a name="l01527"></a>01527                         }
<a name="l01528"></a>01528                         ocy = cy;
<a name="l01529"></a>01529                 }
<a name="l01530"></a>01530                 <span class="keywordflow">if</span> (ocx != cx) {
<a name="l01531"></a>01531                         <span class="keywordflow">if</span> (cx != cy) {
<a name="l01532"></a>01532                                 <span class="keywordflow">if</span> (cx &gt; 0) {
<a name="l01533"></a>01533                                         ypcx = y + cx;
<a name="l01534"></a>01534                                         ymcx = y - cx;
<a name="l01535"></a>01535                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcy, xpcy, ymcx);
<a name="l01536"></a>01536                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcy, xpcy, ypcx);
<a name="l01537"></a>01537                                 } <span class="keywordflow">else</span> {
<a name="l01538"></a>01538                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmcy, xpcy, y);
<a name="l01539"></a>01539                                 }
<a name="l01540"></a>01540                         }
<a name="l01541"></a>01541                         ocx = cx;
<a name="l01542"></a>01542                 }
<a name="l01543"></a>01543 
<a name="l01544"></a>01544                 <span class="comment">/*</span>
<a name="l01545"></a>01545 <span class="comment">                * Update </span>
<a name="l01546"></a>01546 <span class="comment">                */</span>
<a name="l01547"></a>01547                 <span class="keywordflow">if</span> (df &lt; 0) {
<a name="l01548"></a>01548                         df += d_e;
<a name="l01549"></a>01549                         d_e += 2;
<a name="l01550"></a>01550                         d_se += 2;
<a name="l01551"></a>01551                 } <span class="keywordflow">else</span> {
<a name="l01552"></a>01552                         df += d_se;
<a name="l01553"></a>01553                         d_e += 2;
<a name="l01554"></a>01554                         d_se += 4;
<a name="l01555"></a>01555                         cy--;
<a name="l01556"></a>01556                 }
<a name="l01557"></a>01557                 cx++;
<a name="l01558"></a>01558         } <span class="keywordflow">while</span> (cx &lt;= cy);
<a name="l01559"></a>01559 
<a name="l01560"></a>01560         <span class="keywordflow">return</span> (result);
<a name="l01561"></a>01561 }
<a name="l01562"></a>01562 
<a name="l01563"></a>01563 <span class="comment">/* ----- Ellipse */</span>
<a name="l01564"></a>01564 
<a name="l01577"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a9ac841634751689ddb1c26babe10f3f6">01577</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a9518a381e2b09c6b4e45109e68ee0b64" title="Draw ellipse with blending.">ellipseColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
<a name="l01578"></a>01578 {
<a name="l01579"></a>01579         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l01580"></a>01580         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a15eed0329a3aa0642cc0b743262cacb3" title="Draw ellipse with blending.">ellipseRGBA</a>(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
<a name="l01581"></a>01581 }
<a name="l01582"></a>01582 
<a name="l01598"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a3ed26f8b2a25cb94a6412aa772f533aa">01598</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a15eed0329a3aa0642cc0b743262cacb3" title="Draw ellipse with blending.">ellipseRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l01599"></a>01599 {
<a name="l01600"></a>01600         <span class="keywordtype">int</span> result;
<a name="l01601"></a>01601         <span class="keywordtype">int</span> ix, iy;
<a name="l01602"></a>01602         <span class="keywordtype">int</span> h, i, j, k;
<a name="l01603"></a>01603         <span class="keywordtype">int</span> oh, oi, oj, ok;
<a name="l01604"></a>01604         <span class="keywordtype">int</span> xmh, xph, ypk, ymk;
<a name="l01605"></a>01605         <span class="keywordtype">int</span> xmi, xpi, ymj, ypj;
<a name="l01606"></a>01606         <span class="keywordtype">int</span> xmj, xpj, ymi, ypi;
<a name="l01607"></a>01607         <span class="keywordtype">int</span> xmk, xpk, ymh, yph;
<a name="l01608"></a>01608 
<a name="l01609"></a>01609         <span class="comment">/*</span>
<a name="l01610"></a>01610 <span class="comment">        * Sanity check radii </span>
<a name="l01611"></a>01611 <span class="comment">        */</span>
<a name="l01612"></a>01612         <span class="keywordflow">if</span> ((rx &lt; 0) || (ry &lt; 0)) {
<a name="l01613"></a>01613                 <span class="keywordflow">return</span> (-1);
<a name="l01614"></a>01614         }
<a name="l01615"></a>01615 
<a name="l01616"></a>01616         <span class="comment">/*</span>
<a name="l01617"></a>01617 <span class="comment">        * Special case for rx=0 - draw a vline </span>
<a name="l01618"></a>01618 <span class="comment">        */</span>
<a name="l01619"></a>01619         <span class="keywordflow">if</span> (rx == 0) {
<a name="l01620"></a>01620                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x, y - ry, y + ry, r, g, b, a));
<a name="l01621"></a>01621         }
<a name="l01622"></a>01622         <span class="comment">/*</span>
<a name="l01623"></a>01623 <span class="comment">        * Special case for ry=0 - draw a hline </span>
<a name="l01624"></a>01624 <span class="comment">        */</span>
<a name="l01625"></a>01625         <span class="keywordflow">if</span> (ry == 0) {
<a name="l01626"></a>01626                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x - rx, x + rx, y, r, g, b, a));
<a name="l01627"></a>01627         }
<a name="l01628"></a>01628 
<a name="l01629"></a>01629         <span class="comment">/*</span>
<a name="l01630"></a>01630 <span class="comment">        * Set color</span>
<a name="l01631"></a>01631 <span class="comment">        */</span>
<a name="l01632"></a>01632         result = 0;
<a name="l01633"></a>01633         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l01634"></a>01634         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l01635"></a>01635 
<a name="l01636"></a>01636         <span class="comment">/*</span>
<a name="l01637"></a>01637 <span class="comment">        * Init vars </span>
<a name="l01638"></a>01638 <span class="comment">        */</span>
<a name="l01639"></a>01639         oh = oi = oj = ok = 0xFFFF;
<a name="l01640"></a>01640 
<a name="l01641"></a>01641         <span class="comment">/*</span>
<a name="l01642"></a>01642 <span class="comment">        * Draw </span>
<a name="l01643"></a>01643 <span class="comment">        */</span>
<a name="l01644"></a>01644         <span class="keywordflow">if</span> (rx &gt; ry) {
<a name="l01645"></a>01645                 ix = 0;
<a name="l01646"></a>01646                 iy = rx * 64;
<a name="l01647"></a>01647 
<a name="l01648"></a>01648                 <span class="keywordflow">do</span> {
<a name="l01649"></a>01649                         h = (ix + 32) &gt;&gt; 6;
<a name="l01650"></a>01650                         i = (iy + 32) &gt;&gt; 6;
<a name="l01651"></a>01651                         j = (h * ry) / rx;
<a name="l01652"></a>01652                         k = (i * ry) / rx;
<a name="l01653"></a>01653 
<a name="l01654"></a>01654                         <span class="keywordflow">if</span> (((ok != k) &amp;&amp; (oj != k)) || ((oj != j) &amp;&amp; (ok != j)) || (k != j)) {
<a name="l01655"></a>01655                                 xph = x + h;
<a name="l01656"></a>01656                                 xmh = x - h;
<a name="l01657"></a>01657                                 <span class="keywordflow">if</span> (k &gt; 0) {
<a name="l01658"></a>01658                                         ypk = y + k;
<a name="l01659"></a>01659                                         ymk = y - k;
<a name="l01660"></a>01660                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmh, ypk);
<a name="l01661"></a>01661                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xph, ypk);
<a name="l01662"></a>01662                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmh, ymk);
<a name="l01663"></a>01663                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xph, ymk);
<a name="l01664"></a>01664                                 } <span class="keywordflow">else</span> {
<a name="l01665"></a>01665                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmh, y);
<a name="l01666"></a>01666                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xph, y);
<a name="l01667"></a>01667                                 }
<a name="l01668"></a>01668                                 ok = k;
<a name="l01669"></a>01669                                 xpi = x + i;
<a name="l01670"></a>01670                                 xmi = x - i;
<a name="l01671"></a>01671                                 <span class="keywordflow">if</span> (j &gt; 0) {
<a name="l01672"></a>01672                                         ypj = y + j;
<a name="l01673"></a>01673                                         ymj = y - j;
<a name="l01674"></a>01674                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmi, ypj);
<a name="l01675"></a>01675                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpi, ypj);
<a name="l01676"></a>01676                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmi, ymj);
<a name="l01677"></a>01677                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpi, ymj);
<a name="l01678"></a>01678                                 } <span class="keywordflow">else</span> {
<a name="l01679"></a>01679                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmi, y);
<a name="l01680"></a>01680                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpi, y);
<a name="l01681"></a>01681                                 }
<a name="l01682"></a>01682                                 oj = j;
<a name="l01683"></a>01683                         }
<a name="l01684"></a>01684 
<a name="l01685"></a>01685                         ix = ix + iy / rx;
<a name="l01686"></a>01686                         iy = iy - ix / rx;
<a name="l01687"></a>01687 
<a name="l01688"></a>01688                 } <span class="keywordflow">while</span> (i &gt; h);
<a name="l01689"></a>01689         } <span class="keywordflow">else</span> {
<a name="l01690"></a>01690                 ix = 0;
<a name="l01691"></a>01691                 iy = ry * 64;
<a name="l01692"></a>01692 
<a name="l01693"></a>01693                 <span class="keywordflow">do</span> {
<a name="l01694"></a>01694                         h = (ix + 32) &gt;&gt; 6;
<a name="l01695"></a>01695                         i = (iy + 32) &gt;&gt; 6;
<a name="l01696"></a>01696                         j = (h * rx) / ry;
<a name="l01697"></a>01697                         k = (i * rx) / ry;
<a name="l01698"></a>01698 
<a name="l01699"></a>01699                         <span class="keywordflow">if</span> (((oi != i) &amp;&amp; (oh != i)) || ((oh != h) &amp;&amp; (oi != h) &amp;&amp; (i != h))) {
<a name="l01700"></a>01700                                 xmj = x - j;
<a name="l01701"></a>01701                                 xpj = x + j;
<a name="l01702"></a>01702                                 <span class="keywordflow">if</span> (i &gt; 0) {
<a name="l01703"></a>01703                                         ypi = y + i;
<a name="l01704"></a>01704                                         ymi = y - i;
<a name="l01705"></a>01705                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmj, ypi);
<a name="l01706"></a>01706                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpj, ypi);
<a name="l01707"></a>01707                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmj, ymi);
<a name="l01708"></a>01708                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpj, ymi);
<a name="l01709"></a>01709                                 } <span class="keywordflow">else</span> {
<a name="l01710"></a>01710                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmj, y);
<a name="l01711"></a>01711                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpj, y);
<a name="l01712"></a>01712                                 }
<a name="l01713"></a>01713                                 oi = i;
<a name="l01714"></a>01714                                 xmk = x - k;
<a name="l01715"></a>01715                                 xpk = x + k;
<a name="l01716"></a>01716                                 <span class="keywordflow">if</span> (h &gt; 0) {
<a name="l01717"></a>01717                                         yph = y + h;
<a name="l01718"></a>01718                                         ymh = y - h;
<a name="l01719"></a>01719                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmk, yph);
<a name="l01720"></a>01720                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpk, yph);
<a name="l01721"></a>01721                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmk, ymh);
<a name="l01722"></a>01722                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpk, ymh);
<a name="l01723"></a>01723                                 } <span class="keywordflow">else</span> {
<a name="l01724"></a>01724                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xmk, y);
<a name="l01725"></a>01725                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(renderer, xpk, y);
<a name="l01726"></a>01726                                 }
<a name="l01727"></a>01727                                 oh = h;
<a name="l01728"></a>01728                         }
<a name="l01729"></a>01729 
<a name="l01730"></a>01730                         ix = ix + iy / ry;
<a name="l01731"></a>01731                         iy = iy - ix / ry;
<a name="l01732"></a>01732 
<a name="l01733"></a>01733                 } <span class="keywordflow">while</span> (i &gt; h);
<a name="l01734"></a>01734         }
<a name="l01735"></a>01735 
<a name="l01736"></a>01736         <span class="keywordflow">return</span> (result);
<a name="l01737"></a>01737 }
<a name="l01738"></a>01738 
<a name="l01739"></a>01739 <span class="comment">/* ----- AA Ellipse */</span>
<a name="l01740"></a>01740 
<a name="l01741"></a>01741 <span class="comment">/* Windows targets do not have lrint, so provide a local inline version */</span>
<a name="l01742"></a>01742 <span class="preprocessor">#if defined(_MSC_VER)</span>
<a name="l01743"></a>01743 <span class="preprocessor"></span><span class="comment">/* Detect 64bit and use intrinsic version */</span>
<a name="l01744"></a>01744 <span class="preprocessor">#ifdef _M_X64</span>
<a name="l01745"></a>01745 <span class="preprocessor"></span><span class="preprocessor">#include &lt;emmintrin.h&gt;</span>
<a name="l01746"></a>01746 <span class="keyword">static</span> __inline <span class="keywordtype">long</span> 
<a name="l01747"></a>01747         lrint(<span class="keywordtype">float</span> f) 
<a name="l01748"></a>01748 {
<a name="l01749"></a>01749         <span class="keywordflow">return</span> _mm_cvtss_si32(_mm_load_ss(&amp;f));
<a name="l01750"></a>01750 }
<a name="l01751"></a>01751 <span class="preprocessor">#elif defined(_M_IX86)</span>
<a name="l01752"></a>01752 <span class="preprocessor"></span>__inline <span class="keywordtype">long</span> <span class="keywordtype">int</span>
<a name="l01753"></a>01753         lrint (<span class="keywordtype">double</span> flt)
<a name="l01754"></a>01754 {       
<a name="l01755"></a>01755         <span class="keywordtype">int</span> intgr;
<a name="l01756"></a>01756         _asm
<a name="l01757"></a>01757         {
<a name="l01758"></a>01758                 fld flt
<a name="l01759"></a>01759                         fistp intgr
<a name="l01760"></a>01760         };
<a name="l01761"></a>01761         <span class="keywordflow">return</span> intgr;
<a name="l01762"></a>01762 }
<a name="l01763"></a>01763 <span class="preprocessor">#elif defined(_M_ARM)</span>
<a name="l01764"></a>01764 <span class="preprocessor"></span><span class="preprocessor">#include &lt;armintr.h&gt;</span>
<a name="l01765"></a>01765 <span class="preprocessor">#pragma warning(push)</span>
<a name="l01766"></a>01766 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(disable: 4716)</span>
<a name="l01767"></a>01767 <span class="preprocessor"></span>__declspec(naked) long <span class="keywordtype">int</span>
<a name="l01768"></a>01768         lrint (<span class="keywordtype">double</span> flt)
<a name="l01769"></a>01769 {
<a name="l01770"></a>01770         __emit(0xEC410B10); <span class="comment">// fmdrr  d0, r0, r1</span>
<a name="l01771"></a>01771         __emit(0xEEBD0B40); <span class="comment">// ftosid s0, d0</span>
<a name="l01772"></a>01772         __emit(0xEE100A10); <span class="comment">// fmrs   r0, s0</span>
<a name="l01773"></a>01773         __emit(0xE12FFF1E); <span class="comment">// bx     lr</span>
<a name="l01774"></a>01774 }
<a name="l01775"></a>01775 <span class="preprocessor">#pragma warning(pop)</span>
<a name="l01776"></a>01776 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l01777"></a>01777 <span class="preprocessor"></span><span class="preprocessor">#error lrint needed for MSVC on non X86/AMD64/ARM targets.</span>
<a name="l01778"></a>01778 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l01779"></a>01779 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l01780"></a>01780 <span class="preprocessor"></span>
<a name="l01793"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#af676a520e9ea0deabe711da842bc1e55">01793</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#afbbdafd41beaa591c90f5e936d6765a7" title="Draw anti-aliased ellipse with blending.">aaellipseColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
<a name="l01794"></a>01794 {
<a name="l01795"></a>01795         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l01796"></a>01796         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac5714e2b6a067371ae94ee47b834e36a" title="Draw anti-aliased ellipse with blending.">aaellipseRGBA</a>(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
<a name="l01797"></a>01797 }
<a name="l01798"></a>01798 
<a name="l01814"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a12e9ff795a5b9996f07f5b0bc4f60f81">01814</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac5714e2b6a067371ae94ee47b834e36a" title="Draw anti-aliased ellipse with blending.">aaellipseRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l01815"></a>01815 {
<a name="l01816"></a>01816         <span class="keywordtype">int</span> result;
<a name="l01817"></a>01817         <span class="keywordtype">int</span> i;
<a name="l01818"></a>01818         <span class="keywordtype">int</span> a2, b2, ds, dt, dxt, t, s, d;
<a name="l01819"></a>01819         Sint16 xp, yp, xs, ys, dyt, od, xx, yy, xc2, yc2;
<a name="l01820"></a>01820         <span class="keywordtype">float</span> cp;
<a name="l01821"></a>01821         <span class="keywordtype">double</span> sab;
<a name="l01822"></a>01822         Uint8 weight, iweight;
<a name="l01823"></a>01823 
<a name="l01824"></a>01824         <span class="comment">/*</span>
<a name="l01825"></a>01825 <span class="comment">        * Sanity check radii </span>
<a name="l01826"></a>01826 <span class="comment">        */</span>
<a name="l01827"></a>01827         <span class="keywordflow">if</span> ((rx &lt; 0) || (ry &lt; 0)) {
<a name="l01828"></a>01828                 <span class="keywordflow">return</span> (-1);
<a name="l01829"></a>01829         }
<a name="l01830"></a>01830 
<a name="l01831"></a>01831         <span class="comment">/*</span>
<a name="l01832"></a>01832 <span class="comment">        * Special case for rx=0 - draw a vline </span>
<a name="l01833"></a>01833 <span class="comment">        */</span>
<a name="l01834"></a>01834         <span class="keywordflow">if</span> (rx == 0) {
<a name="l01835"></a>01835                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x, y - ry, y + ry, r, g, b, a));
<a name="l01836"></a>01836         }
<a name="l01837"></a>01837         <span class="comment">/*</span>
<a name="l01838"></a>01838 <span class="comment">        * Special case for ry=0 - draw an hline </span>
<a name="l01839"></a>01839 <span class="comment">        */</span>
<a name="l01840"></a>01840         <span class="keywordflow">if</span> (ry == 0) {
<a name="l01841"></a>01841                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x - rx, x + rx, y, r, g, b, a));
<a name="l01842"></a>01842         }
<a name="l01843"></a>01843 
<a name="l01844"></a>01844         <span class="comment">/* Variable setup */</span>
<a name="l01845"></a>01845         a2 = rx * rx;
<a name="l01846"></a>01846         b2 = ry * ry;
<a name="l01847"></a>01847 
<a name="l01848"></a>01848         ds = 2 * a2;
<a name="l01849"></a>01849         dt = 2 * b2;
<a name="l01850"></a>01850 
<a name="l01851"></a>01851         xc2 = 2 * x;
<a name="l01852"></a>01852         yc2 = 2 * y;
<a name="l01853"></a>01853 
<a name="l01854"></a>01854         sab = sqrt((<span class="keywordtype">double</span>)(a2 + b2));
<a name="l01855"></a>01855         od = (Sint16)lrint(sab*0.01) + 1; <span class="comment">/* introduce some overdraw */</span>
<a name="l01856"></a>01856         dxt = (Sint16)lrint((<span class="keywordtype">double</span>)a2 / sab) + od;
<a name="l01857"></a>01857 
<a name="l01858"></a>01858         t = 0;
<a name="l01859"></a>01859         s = -2 * a2 * ry;
<a name="l01860"></a>01860         d = 0;
<a name="l01861"></a>01861 
<a name="l01862"></a>01862         xp = x;
<a name="l01863"></a>01863         yp = y - ry;
<a name="l01864"></a>01864 
<a name="l01865"></a>01865         <span class="comment">/* Draw */</span>
<a name="l01866"></a>01866         result = 0;
<a name="l01867"></a>01867         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l01868"></a>01868 
<a name="l01869"></a>01869         <span class="comment">/* &quot;End points&quot; */</span>
<a name="l01870"></a>01870         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, xp, yp, r, g, b, a);
<a name="l01871"></a>01871         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, xc2 - xp, yp, r, g, b, a);
<a name="l01872"></a>01872         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, xp, yc2 - yp, r, g, b, a);
<a name="l01873"></a>01873         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, xc2 - xp, yc2 - yp, r, g, b, a);
<a name="l01874"></a>01874 
<a name="l01875"></a>01875         <span class="keywordflow">for</span> (i = 1; i &lt;= dxt; i++) {
<a name="l01876"></a>01876                 xp--;
<a name="l01877"></a>01877                 d += t - b2;
<a name="l01878"></a>01878 
<a name="l01879"></a>01879                 <span class="keywordflow">if</span> (d &gt;= 0)
<a name="l01880"></a>01880                         ys = yp - 1;
<a name="l01881"></a>01881                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((d - s - a2) &gt; 0) {
<a name="l01882"></a>01882                         <span class="keywordflow">if</span> ((2 * d - s - a2) &gt;= 0)
<a name="l01883"></a>01883                                 ys = yp + 1;
<a name="l01884"></a>01884                         <span class="keywordflow">else</span> {
<a name="l01885"></a>01885                                 ys = yp;
<a name="l01886"></a>01886                                 yp++;
<a name="l01887"></a>01887                                 d -= s + a2;
<a name="l01888"></a>01888                                 s += ds;
<a name="l01889"></a>01889                         }
<a name="l01890"></a>01890                 } <span class="keywordflow">else</span> {
<a name="l01891"></a>01891                         yp++;
<a name="l01892"></a>01892                         ys = yp + 1;
<a name="l01893"></a>01893                         d -= s + a2;
<a name="l01894"></a>01894                         s += ds;
<a name="l01895"></a>01895                 }
<a name="l01896"></a>01896 
<a name="l01897"></a>01897                 t -= dt;
<a name="l01898"></a>01898 
<a name="l01899"></a>01899                 <span class="comment">/* Calculate alpha */</span>
<a name="l01900"></a>01900                 <span class="keywordflow">if</span> (s != 0) {
<a name="l01901"></a>01901                         cp = (float) abs(d) / (float) abs(s);
<a name="l01902"></a>01902                         <span class="keywordflow">if</span> (cp &gt; 1.0) {
<a name="l01903"></a>01903                                 cp = 1.0;
<a name="l01904"></a>01904                         }
<a name="l01905"></a>01905                 } <span class="keywordflow">else</span> {
<a name="l01906"></a>01906                         cp = 1.0;
<a name="l01907"></a>01907                 }
<a name="l01908"></a>01908 
<a name="l01909"></a>01909                 <span class="comment">/* Calculate weights */</span>
<a name="l01910"></a>01910                 weight = (Uint8) (cp * 255);
<a name="l01911"></a>01911                 iweight = 255 - weight;
<a name="l01912"></a>01912 
<a name="l01913"></a>01913                 <span class="comment">/* Upper half */</span>
<a name="l01914"></a>01914                 xx = xc2 - xp;
<a name="l01915"></a>01915                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xp, yp, r, g, b, a, iweight);
<a name="l01916"></a>01916                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, yp, r, g, b, a, iweight);
<a name="l01917"></a>01917 
<a name="l01918"></a>01918                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xp, ys, r, g, b, a, weight);
<a name="l01919"></a>01919                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, ys, r, g, b, a, weight);
<a name="l01920"></a>01920 
<a name="l01921"></a>01921                 <span class="comment">/* Lower half */</span>
<a name="l01922"></a>01922                 yy = yc2 - yp;
<a name="l01923"></a>01923                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xp, yy, r, g, b, a, iweight);
<a name="l01924"></a>01924                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, yy, r, g, b, a, iweight);
<a name="l01925"></a>01925 
<a name="l01926"></a>01926                 yy = yc2 - ys;
<a name="l01927"></a>01927                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xp, yy, r, g, b, a, weight);
<a name="l01928"></a>01928                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, yy, r, g, b, a, weight);
<a name="l01929"></a>01929         }
<a name="l01930"></a>01930 
<a name="l01931"></a>01931         <span class="comment">/* Replaces original approximation code dyt = abs(yp - yc); */</span>
<a name="l01932"></a>01932         dyt = (Sint16)lrint((<span class="keywordtype">double</span>)b2 / sab ) + od;    
<a name="l01933"></a>01933 
<a name="l01934"></a>01934         <span class="keywordflow">for</span> (i = 1; i &lt;= dyt; i++) {
<a name="l01935"></a>01935                 yp++;
<a name="l01936"></a>01936                 d -= s + a2;
<a name="l01937"></a>01937 
<a name="l01938"></a>01938                 <span class="keywordflow">if</span> (d &lt;= 0)
<a name="l01939"></a>01939                         xs = xp + 1;
<a name="l01940"></a>01940                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((d + t - b2) &lt; 0) {
<a name="l01941"></a>01941                         <span class="keywordflow">if</span> ((2 * d + t - b2) &lt;= 0)
<a name="l01942"></a>01942                                 xs = xp - 1;
<a name="l01943"></a>01943                         <span class="keywordflow">else</span> {
<a name="l01944"></a>01944                                 xs = xp;
<a name="l01945"></a>01945                                 xp--;
<a name="l01946"></a>01946                                 d += t - b2;
<a name="l01947"></a>01947                                 t -= dt;
<a name="l01948"></a>01948                         }
<a name="l01949"></a>01949                 } <span class="keywordflow">else</span> {
<a name="l01950"></a>01950                         xp--;
<a name="l01951"></a>01951                         xs = xp - 1;
<a name="l01952"></a>01952                         d += t - b2;
<a name="l01953"></a>01953                         t -= dt;
<a name="l01954"></a>01954                 }
<a name="l01955"></a>01955 
<a name="l01956"></a>01956                 s += ds;
<a name="l01957"></a>01957 
<a name="l01958"></a>01958                 <span class="comment">/* Calculate alpha */</span>
<a name="l01959"></a>01959                 <span class="keywordflow">if</span> (t != 0) {
<a name="l01960"></a>01960                         cp = (float) abs(d) / (float) abs(t);
<a name="l01961"></a>01961                         <span class="keywordflow">if</span> (cp &gt; 1.0) {
<a name="l01962"></a>01962                                 cp = 1.0;
<a name="l01963"></a>01963                         }
<a name="l01964"></a>01964                 } <span class="keywordflow">else</span> {
<a name="l01965"></a>01965                         cp = 1.0;
<a name="l01966"></a>01966                 }
<a name="l01967"></a>01967 
<a name="l01968"></a>01968                 <span class="comment">/* Calculate weight */</span>
<a name="l01969"></a>01969                 weight = (Uint8) (cp * 255);
<a name="l01970"></a>01970                 iweight = 255 - weight;
<a name="l01971"></a>01971 
<a name="l01972"></a>01972                 <span class="comment">/* Left half */</span>
<a name="l01973"></a>01973                 xx = xc2 - xp;
<a name="l01974"></a>01974                 yy = yc2 - yp;
<a name="l01975"></a>01975                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xp, yp, r, g, b, a, iweight);
<a name="l01976"></a>01976                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, yp, r, g, b, a, iweight);
<a name="l01977"></a>01977 
<a name="l01978"></a>01978                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xp, yy, r, g, b, a, iweight);
<a name="l01979"></a>01979                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, yy, r, g, b, a, iweight);
<a name="l01980"></a>01980 
<a name="l01981"></a>01981                 <span class="comment">/* Right half */</span>
<a name="l01982"></a>01982                 xx = xc2 - xs;
<a name="l01983"></a>01983                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xs, yp, r, g, b, a, weight);
<a name="l01984"></a>01984                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, yp, r, g, b, a, weight);
<a name="l01985"></a>01985 
<a name="l01986"></a>01986                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xs, yy, r, g, b, a, weight);
<a name="l01987"></a>01987                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a1f205b54bc806e64c475941e8e7f3cbf" title="Draw pixel with blending enabled and using alpha weight on color.">pixelRGBAWeight</a>(renderer, xx, yy, r, g, b, a, weight);                
<a name="l01988"></a>01988         }
<a name="l01989"></a>01989 
<a name="l01990"></a>01990         <span class="keywordflow">return</span> (result);
<a name="l01991"></a>01991 }
<a name="l01992"></a>01992 
<a name="l01993"></a>01993 <span class="comment">/* ---- Filled Ellipse */</span>
<a name="l01994"></a>01994 
<a name="l02007"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#aa3119e2dd056874c0ca92ded41fea43c">02007</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a5477c5b33b56937f6129438a5fb99c70" title="Draw filled ellipse with blending.">filledEllipseColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color)
<a name="l02008"></a>02008 {
<a name="l02009"></a>02009         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l02010"></a>02010         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a40aad9eb1dc3000251712c1e16dacd26" title="Draw filled ellipse with blending.">filledEllipseRGBA</a>(renderer, x, y, rx, ry, c[0], c[1], c[2], c[3]);
<a name="l02011"></a>02011 }
<a name="l02012"></a>02012 
<a name="l02028"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a5240918c243c3e60dd8ae1cef50dd529">02028</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a40aad9eb1dc3000251712c1e16dacd26" title="Draw filled ellipse with blending.">filledEllipseRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02029"></a>02029 {
<a name="l02030"></a>02030         <span class="keywordtype">int</span> result;
<a name="l02031"></a>02031         <span class="keywordtype">int</span> ix, iy;
<a name="l02032"></a>02032         <span class="keywordtype">int</span> h, i, j, k;
<a name="l02033"></a>02033         <span class="keywordtype">int</span> oh, oi, oj, ok;
<a name="l02034"></a>02034         <span class="keywordtype">int</span> xmh, xph;
<a name="l02035"></a>02035         <span class="keywordtype">int</span> xmi, xpi;
<a name="l02036"></a>02036         <span class="keywordtype">int</span> xmj, xpj;
<a name="l02037"></a>02037         <span class="keywordtype">int</span> xmk, xpk;
<a name="l02038"></a>02038 
<a name="l02039"></a>02039         <span class="comment">/*</span>
<a name="l02040"></a>02040 <span class="comment">        * Sanity check radii </span>
<a name="l02041"></a>02041 <span class="comment">        */</span>
<a name="l02042"></a>02042         <span class="keywordflow">if</span> ((rx &lt; 0) || (ry &lt; 0)) {
<a name="l02043"></a>02043                 <span class="keywordflow">return</span> (-1);
<a name="l02044"></a>02044         }
<a name="l02045"></a>02045 
<a name="l02046"></a>02046         <span class="comment">/*</span>
<a name="l02047"></a>02047 <span class="comment">        * Special case for rx=0 - draw a vline </span>
<a name="l02048"></a>02048 <span class="comment">        */</span>
<a name="l02049"></a>02049         <span class="keywordflow">if</span> (rx == 0) {
<a name="l02050"></a>02050                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a7a8eff7484a2b663bde190caa02acd27" title="Draw vertical line with blending.">vlineRGBA</a>(renderer, x, y - ry, y + ry, r, g, b, a));
<a name="l02051"></a>02051         }
<a name="l02052"></a>02052         <span class="comment">/*</span>
<a name="l02053"></a>02053 <span class="comment">        * Special case for ry=0 - draw a hline </span>
<a name="l02054"></a>02054 <span class="comment">        */</span>
<a name="l02055"></a>02055         <span class="keywordflow">if</span> (ry == 0) {
<a name="l02056"></a>02056                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6a0d6ec83f217988a463f65f7c58cabe" title="Draw horizontal line with blending.">hlineRGBA</a>(renderer, x - rx, x + rx, y, r, g, b, a));
<a name="l02057"></a>02057         }
<a name="l02058"></a>02058 
<a name="l02059"></a>02059         <span class="comment">/*</span>
<a name="l02060"></a>02060 <span class="comment">        * Set color</span>
<a name="l02061"></a>02061 <span class="comment">        */</span>
<a name="l02062"></a>02062         result = 0;
<a name="l02063"></a>02063         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l02064"></a>02064         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l02065"></a>02065 
<a name="l02066"></a>02066         <span class="comment">/*</span>
<a name="l02067"></a>02067 <span class="comment">        * Init vars </span>
<a name="l02068"></a>02068 <span class="comment">        */</span>
<a name="l02069"></a>02069         oh = oi = oj = ok = 0xFFFF;
<a name="l02070"></a>02070 
<a name="l02071"></a>02071         <span class="comment">/*</span>
<a name="l02072"></a>02072 <span class="comment">        * Draw </span>
<a name="l02073"></a>02073 <span class="comment">        */</span>
<a name="l02074"></a>02074         <span class="keywordflow">if</span> (rx &gt; ry) {
<a name="l02075"></a>02075                 ix = 0;
<a name="l02076"></a>02076                 iy = rx * 64;
<a name="l02077"></a>02077 
<a name="l02078"></a>02078                 <span class="keywordflow">do</span> {
<a name="l02079"></a>02079                         h = (ix + 32) &gt;&gt; 6;
<a name="l02080"></a>02080                         i = (iy + 32) &gt;&gt; 6;
<a name="l02081"></a>02081                         j = (h * ry) / rx;
<a name="l02082"></a>02082                         k = (i * ry) / rx;
<a name="l02083"></a>02083 
<a name="l02084"></a>02084                         <span class="keywordflow">if</span> ((ok != k) &amp;&amp; (oj != k)) {
<a name="l02085"></a>02085                                 xph = x + h;
<a name="l02086"></a>02086                                 xmh = x - h;
<a name="l02087"></a>02087                                 <span class="keywordflow">if</span> (k &gt; 0) {
<a name="l02088"></a>02088                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmh, xph, y + k);
<a name="l02089"></a>02089                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmh, xph, y - k);
<a name="l02090"></a>02090                                 } <span class="keywordflow">else</span> {
<a name="l02091"></a>02091                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmh, xph, y);
<a name="l02092"></a>02092                                 }
<a name="l02093"></a>02093                                 ok = k;
<a name="l02094"></a>02094                         }
<a name="l02095"></a>02095                         <span class="keywordflow">if</span> ((oj != j) &amp;&amp; (ok != j) &amp;&amp; (k != j)) {
<a name="l02096"></a>02096                                 xmi = x - i;
<a name="l02097"></a>02097                                 xpi = x + i;
<a name="l02098"></a>02098                                 <span class="keywordflow">if</span> (j &gt; 0) {
<a name="l02099"></a>02099                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmi, xpi, y + j);
<a name="l02100"></a>02100                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmi, xpi, y - j);
<a name="l02101"></a>02101                                 } <span class="keywordflow">else</span> {
<a name="l02102"></a>02102                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmi, xpi, y);
<a name="l02103"></a>02103                                 }
<a name="l02104"></a>02104                                 oj = j;
<a name="l02105"></a>02105                         }
<a name="l02106"></a>02106 
<a name="l02107"></a>02107                         ix = ix + iy / rx;
<a name="l02108"></a>02108                         iy = iy - ix / rx;
<a name="l02109"></a>02109 
<a name="l02110"></a>02110                 } <span class="keywordflow">while</span> (i &gt; h);
<a name="l02111"></a>02111         } <span class="keywordflow">else</span> {
<a name="l02112"></a>02112                 ix = 0;
<a name="l02113"></a>02113                 iy = ry * 64;
<a name="l02114"></a>02114 
<a name="l02115"></a>02115                 <span class="keywordflow">do</span> {
<a name="l02116"></a>02116                         h = (ix + 32) &gt;&gt; 6;
<a name="l02117"></a>02117                         i = (iy + 32) &gt;&gt; 6;
<a name="l02118"></a>02118                         j = (h * rx) / ry;
<a name="l02119"></a>02119                         k = (i * rx) / ry;
<a name="l02120"></a>02120 
<a name="l02121"></a>02121                         <span class="keywordflow">if</span> ((oi != i) &amp;&amp; (oh != i)) {
<a name="l02122"></a>02122                                 xmj = x - j;
<a name="l02123"></a>02123                                 xpj = x + j;
<a name="l02124"></a>02124                                 <span class="keywordflow">if</span> (i &gt; 0) {
<a name="l02125"></a>02125                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmj, xpj, y + i);
<a name="l02126"></a>02126                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmj, xpj, y - i);
<a name="l02127"></a>02127                                 } <span class="keywordflow">else</span> {
<a name="l02128"></a>02128                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmj, xpj, y);
<a name="l02129"></a>02129                                 }
<a name="l02130"></a>02130                                 oi = i;
<a name="l02131"></a>02131                         }
<a name="l02132"></a>02132                         <span class="keywordflow">if</span> ((oh != h) &amp;&amp; (oi != h) &amp;&amp; (i != h)) {
<a name="l02133"></a>02133                                 xmk = x - k;
<a name="l02134"></a>02134                                 xpk = x + k;
<a name="l02135"></a>02135                                 <span class="keywordflow">if</span> (h &gt; 0) {
<a name="l02136"></a>02136                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmk, xpk, y + h);
<a name="l02137"></a>02137                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmk, xpk, y - h);
<a name="l02138"></a>02138                                 } <span class="keywordflow">else</span> {
<a name="l02139"></a>02139                                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xmk, xpk, y);
<a name="l02140"></a>02140                                 }
<a name="l02141"></a>02141                                 oh = h;
<a name="l02142"></a>02142                         }
<a name="l02143"></a>02143 
<a name="l02144"></a>02144                         ix = ix + iy / ry;
<a name="l02145"></a>02145                         iy = iy - ix / ry;
<a name="l02146"></a>02146 
<a name="l02147"></a>02147                 } <span class="keywordflow">while</span> (i &gt; h);
<a name="l02148"></a>02148         }
<a name="l02149"></a>02149 
<a name="l02150"></a>02150         <span class="keywordflow">return</span> (result);
<a name="l02151"></a>02151 }
<a name="l02152"></a>02152 
<a name="l02153"></a>02153 <span class="comment">/* ----- Pie */</span>
<a name="l02154"></a>02154 
<a name="l02174"></a>02174 <span class="comment">/* TODO: rewrite algorithm; pie is not always accurate */</span>
<a name="l02175"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a484ac0e6073f11c999841e5d8a25244e">02175</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a484ac0e6073f11c999841e5d8a25244e" title="Internal float (low-speed) pie-calc implementation by drawing polygons.">_pieRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end,  Uint8 r, Uint8 g, Uint8 b, Uint8 a, Uint8 filled)
<a name="l02176"></a>02176 {
<a name="l02177"></a>02177         <span class="keywordtype">int</span> result;
<a name="l02178"></a>02178         <span class="keywordtype">double</span> angle, start_angle, end_angle;
<a name="l02179"></a>02179         <span class="keywordtype">double</span> deltaAngle;
<a name="l02180"></a>02180         <span class="keywordtype">double</span> dr;
<a name="l02181"></a>02181         <span class="keywordtype">int</span> numpoints, i;
<a name="l02182"></a>02182         Sint16 *vx, *vy;
<a name="l02183"></a>02183 
<a name="l02184"></a>02184         <span class="comment">/*</span>
<a name="l02185"></a>02185 <span class="comment">        * Sanity check radii </span>
<a name="l02186"></a>02186 <span class="comment">        */</span>
<a name="l02187"></a>02187         <span class="keywordflow">if</span> (rad &lt; 0) {
<a name="l02188"></a>02188                 <span class="keywordflow">return</span> (-1);
<a name="l02189"></a>02189         }
<a name="l02190"></a>02190 
<a name="l02191"></a>02191         <span class="comment">/*</span>
<a name="l02192"></a>02192 <span class="comment">        * Fixup angles</span>
<a name="l02193"></a>02193 <span class="comment">        */</span>
<a name="l02194"></a>02194         start = start % 360;
<a name="l02195"></a>02195         end = end % 360;
<a name="l02196"></a>02196 
<a name="l02197"></a>02197         <span class="comment">/*</span>
<a name="l02198"></a>02198 <span class="comment">        * Special case for rad=0 - draw a point </span>
<a name="l02199"></a>02199 <span class="comment">        */</span>
<a name="l02200"></a>02200         <span class="keywordflow">if</span> (rad == 0) {
<a name="l02201"></a>02201                 <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ae67cd64db328392941f96c187edafdf3" title="Draw pixel with blending enabled if a&lt;255.">pixelRGBA</a>(renderer, x, y, r, g, b, a));
<a name="l02202"></a>02202         }
<a name="l02203"></a>02203 
<a name="l02204"></a>02204         <span class="comment">/*</span>
<a name="l02205"></a>02205 <span class="comment">        * Variable setup </span>
<a name="l02206"></a>02206 <span class="comment">        */</span>
<a name="l02207"></a>02207         dr = (double) rad;
<a name="l02208"></a>02208         deltaAngle = 3.0 / dr;
<a name="l02209"></a>02209         start_angle = (double) start *(2.0 * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 360.0);
<a name="l02210"></a>02210         end_angle = (double) end *(2.0 * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a> / 360.0);
<a name="l02211"></a>02211         <span class="keywordflow">if</span> (start &gt; end) {
<a name="l02212"></a>02212                 end_angle += (2.0 * <a class="code" href="_s_d_l2__gfx_primitives_8h.html#ae71449b1cc6e6250b91f539153a7a0d3">M_PI</a>);
<a name="l02213"></a>02213         }
<a name="l02214"></a>02214 
<a name="l02215"></a>02215         <span class="comment">/* We will always have at least 2 points */</span>
<a name="l02216"></a>02216         numpoints = 2;
<a name="l02217"></a>02217 
<a name="l02218"></a>02218         <span class="comment">/* Count points (rather than calculating it) */</span>
<a name="l02219"></a>02219         angle = start_angle;
<a name="l02220"></a>02220         <span class="keywordflow">while</span> (angle &lt; end_angle) {
<a name="l02221"></a>02221                 angle += deltaAngle;
<a name="l02222"></a>02222                 numpoints++;
<a name="l02223"></a>02223         }
<a name="l02224"></a>02224 
<a name="l02225"></a>02225         <span class="comment">/* Allocate combined vertex array */</span>
<a name="l02226"></a>02226         vx = vy = (Sint16 *) malloc(2 * <span class="keyword">sizeof</span>(Uint16) * numpoints);
<a name="l02227"></a>02227         <span class="keywordflow">if</span> (vx == NULL) {
<a name="l02228"></a>02228                 <span class="keywordflow">return</span> (-1);
<a name="l02229"></a>02229         }
<a name="l02230"></a>02230 
<a name="l02231"></a>02231         <span class="comment">/* Update point to start of vy */</span>
<a name="l02232"></a>02232         vy += numpoints;
<a name="l02233"></a>02233 
<a name="l02234"></a>02234         <span class="comment">/* Center */</span>
<a name="l02235"></a>02235         vx[0] = x;
<a name="l02236"></a>02236         vy[0] = y;
<a name="l02237"></a>02237 
<a name="l02238"></a>02238         <span class="comment">/* First vertex */</span>
<a name="l02239"></a>02239         angle = start_angle;
<a name="l02240"></a>02240         vx[1] = x + (int) (dr * cos(angle));
<a name="l02241"></a>02241         vy[1] = y + (int) (dr * sin(angle));
<a name="l02242"></a>02242 
<a name="l02243"></a>02243         <span class="keywordflow">if</span> (numpoints&lt;3)
<a name="l02244"></a>02244         {
<a name="l02245"></a>02245                 result = <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a82d13b4ab3057ebebb7706e451090712" title="Draw line with alpha blending.">lineRGBA</a>(renderer, vx[0], vy[0], vx[1], vy[1], r, g, b, a);
<a name="l02246"></a>02246         }
<a name="l02247"></a>02247         <span class="keywordflow">else</span>
<a name="l02248"></a>02248         {
<a name="l02249"></a>02249                 <span class="comment">/* Calculate other vertices */</span>
<a name="l02250"></a>02250                 i = 2;
<a name="l02251"></a>02251                 angle = start_angle;
<a name="l02252"></a>02252                 <span class="keywordflow">while</span> (angle &lt; end_angle) {
<a name="l02253"></a>02253                         angle += deltaAngle;
<a name="l02254"></a>02254                         <span class="keywordflow">if</span> (angle&gt;end_angle)
<a name="l02255"></a>02255                         {
<a name="l02256"></a>02256                                 angle = end_angle;
<a name="l02257"></a>02257                         }
<a name="l02258"></a>02258                         vx[i] = x + (int) (dr * cos(angle));
<a name="l02259"></a>02259                         vy[i] = y + (int) (dr * sin(angle));
<a name="l02260"></a>02260                         i++;
<a name="l02261"></a>02261                 }
<a name="l02262"></a>02262 
<a name="l02263"></a>02263                 <span class="comment">/* Draw */</span>
<a name="l02264"></a>02264                 <span class="keywordflow">if</span> (filled) {
<a name="l02265"></a>02265                         result = <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a31ee2c3d19bd0e9ca5545b81269575a6" title="Draw filled polygon with alpha blending.">filledPolygonRGBA</a>(renderer, vx, vy, numpoints, r, g, b, a);
<a name="l02266"></a>02266                 } <span class="keywordflow">else</span> {
<a name="l02267"></a>02267                         result = <a class="code" href="_s_d_l2__gfx_primitives_8c.html#acf4c333418f95d250528c4106b6ead63" title="Draw polygon with alpha blending.">polygonRGBA</a>(renderer, vx, vy, numpoints, r, g, b, a);
<a name="l02268"></a>02268                 }
<a name="l02269"></a>02269         }
<a name="l02270"></a>02270 
<a name="l02271"></a>02271         <span class="comment">/* Free combined vertex array */</span>
<a name="l02272"></a>02272         free(vx);
<a name="l02273"></a>02273 
<a name="l02274"></a>02274         <span class="keywordflow">return</span> (result);
<a name="l02275"></a>02275 }
<a name="l02276"></a>02276 
<a name="l02290"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a9f9070739e72ea242fd48239a4ff48e4">02290</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a25ffe0578a32b143364d7d9513c3e2a7" title="Draw pie (outline) with alpha blending.">pieColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, 
<a name="l02291"></a>02291         Sint16 start, Sint16 end, Uint32 color) 
<a name="l02292"></a>02292 {
<a name="l02293"></a>02293         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l02294"></a>02294         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a484ac0e6073f11c999841e5d8a25244e" title="Internal float (low-speed) pie-calc implementation by drawing polygons.">_pieRGBA</a>(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 0);
<a name="l02295"></a>02295 }
<a name="l02296"></a>02296 
<a name="l02313"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a3b8baf3eecea4738ac2a1c28af4bfb41">02313</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab5dd5024c52d632bbbd2bdfc801cb81c" title="Draw pie (outline) with alpha blending.">pieRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
<a name="l02314"></a>02314         Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02315"></a>02315 {
<a name="l02316"></a>02316         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a484ac0e6073f11c999841e5d8a25244e" title="Internal float (low-speed) pie-calc implementation by drawing polygons.">_pieRGBA</a>(renderer, x, y, rad, start, end, r, g, b, a, 0);
<a name="l02317"></a>02317 }
<a name="l02318"></a>02318 
<a name="l02332"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a86f189dabaa2a26115ecb819ad7da8e5">02332</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a8b3489682bc4c791228580c0a118f4b9" title="Draw filled pie with alpha blending.">filledPieColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color)
<a name="l02333"></a>02333 {
<a name="l02334"></a>02334         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l02335"></a>02335         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a484ac0e6073f11c999841e5d8a25244e" title="Internal float (low-speed) pie-calc implementation by drawing polygons.">_pieRGBA</a>(renderer, x, y, rad, start, end, c[0], c[1], c[2], c[3], 1);
<a name="l02336"></a>02336 }
<a name="l02337"></a>02337 
<a name="l02354"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#adad0f423ae093b5c3cad51a438954a50">02354</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa49fd970108edd50f895b3eed0a5cf59" title="Draw filled pie with alpha blending.">filledPieRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, Sint16 rad,
<a name="l02355"></a>02355         Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02356"></a>02356 {
<a name="l02357"></a>02357         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a484ac0e6073f11c999841e5d8a25244e" title="Internal float (low-speed) pie-calc implementation by drawing polygons.">_pieRGBA</a>(renderer, x, y, rad, start, end, r, g, b, a, 1);
<a name="l02358"></a>02358 }
<a name="l02359"></a>02359 
<a name="l02360"></a>02360 <span class="comment">/* ------ Trigon */</span>
<a name="l02361"></a>02361 
<a name="l02378"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#af4fc0fdb33e57047d9347d3fe7b1bdbd">02378</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab6ebeb4e37c2709cd413a308da5bea45" title="Draw trigon (triangle outline) with alpha blending.">trigonColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
<a name="l02379"></a>02379 {
<a name="l02380"></a>02380         Sint16 vx[3]; 
<a name="l02381"></a>02381         Sint16 vy[3];
<a name="l02382"></a>02382 
<a name="l02383"></a>02383         vx[0]=x1;
<a name="l02384"></a>02384         vx[1]=x2;
<a name="l02385"></a>02385         vx[2]=x3;
<a name="l02386"></a>02386         vy[0]=y1;
<a name="l02387"></a>02387         vy[1]=y2;
<a name="l02388"></a>02388         vy[2]=y3;
<a name="l02389"></a>02389 
<a name="l02390"></a>02390         <span class="keywordflow">return</span>(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a736477a8ea3068bcc3d8d9af4e07420e" title="Draw polygon with alpha blending.">polygonColor</a>(renderer,vx,vy,3,color));
<a name="l02391"></a>02391 }
<a name="l02392"></a>02392 
<a name="l02410"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a152662f6985587d137837086aaa95311">02410</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aea579ce05e8306113dc7734a542886c4" title="Draw trigon (triangle outline) with alpha blending.">trigonRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
<a name="l02411"></a>02411         Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02412"></a>02412 {
<a name="l02413"></a>02413         Sint16 vx[3]; 
<a name="l02414"></a>02414         Sint16 vy[3];
<a name="l02415"></a>02415 
<a name="l02416"></a>02416         vx[0]=x1;
<a name="l02417"></a>02417         vx[1]=x2;
<a name="l02418"></a>02418         vx[2]=x3;
<a name="l02419"></a>02419         vy[0]=y1;
<a name="l02420"></a>02420         vy[1]=y2;
<a name="l02421"></a>02421         vy[2]=y3;
<a name="l02422"></a>02422 
<a name="l02423"></a>02423         <span class="keywordflow">return</span>(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#acf4c333418f95d250528c4106b6ead63" title="Draw polygon with alpha blending.">polygonRGBA</a>(renderer,vx,vy,3,r,g,b,a));
<a name="l02424"></a>02424 }                                
<a name="l02425"></a>02425 
<a name="l02426"></a>02426 <span class="comment">/* ------ AA-Trigon */</span>
<a name="l02427"></a>02427 
<a name="l02444"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a75bc7cc80beb53452c135e8c1a75d1c5">02444</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a858ecd0d6c3786c6d83dcf273bfcd923" title="Draw anti-aliased trigon (triangle outline) with alpha blending.">aatrigonColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
<a name="l02445"></a>02445 {
<a name="l02446"></a>02446         Sint16 vx[3]; 
<a name="l02447"></a>02447         Sint16 vy[3];
<a name="l02448"></a>02448 
<a name="l02449"></a>02449         vx[0]=x1;
<a name="l02450"></a>02450         vx[1]=x2;
<a name="l02451"></a>02451         vx[2]=x3;
<a name="l02452"></a>02452         vy[0]=y1;
<a name="l02453"></a>02453         vy[1]=y2;
<a name="l02454"></a>02454         vy[2]=y3;
<a name="l02455"></a>02455 
<a name="l02456"></a>02456         <span class="keywordflow">return</span>(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#adb4ea9b9394ef35410e1c4e164110f58" title="Draw anti-aliased polygon with alpha blending.">aapolygonColor</a>(renderer,vx,vy,3,color));
<a name="l02457"></a>02457 }
<a name="l02458"></a>02458 
<a name="l02476"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#aa7fddcf1aa339a825024544fb774aa8f">02476</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6f64baf8a15fcb4681560295c1f0915d" title="Draw anti-aliased trigon (triangle outline) with alpha blending.">aatrigonRGBA</a>(SDL_Renderer * renderer,  Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
<a name="l02477"></a>02477         Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02478"></a>02478 {
<a name="l02479"></a>02479         Sint16 vx[3]; 
<a name="l02480"></a>02480         Sint16 vy[3];
<a name="l02481"></a>02481 
<a name="l02482"></a>02482         vx[0]=x1;
<a name="l02483"></a>02483         vx[1]=x2;
<a name="l02484"></a>02484         vx[2]=x3;
<a name="l02485"></a>02485         vy[0]=y1;
<a name="l02486"></a>02486         vy[1]=y2;
<a name="l02487"></a>02487         vy[2]=y3;
<a name="l02488"></a>02488 
<a name="l02489"></a>02489         <span class="keywordflow">return</span>(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a431337e0736927d3bd5a0c53d1d6091a" title="Draw anti-aliased polygon with alpha blending.">aapolygonRGBA</a>(renderer,vx,vy,3,r,g,b,a));
<a name="l02490"></a>02490 }                                  
<a name="l02491"></a>02491 
<a name="l02492"></a>02492 <span class="comment">/* ------ Filled Trigon */</span>
<a name="l02493"></a>02493 
<a name="l02510"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a57fd7355780a114b9d72b1e9591f955d">02510</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a79efc6451b00c91cf50e46a29dcde230" title="Draw filled trigon (triangle) with alpha blending.">filledTrigonColor</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
<a name="l02511"></a>02511 {
<a name="l02512"></a>02512         Sint16 vx[3]; 
<a name="l02513"></a>02513         Sint16 vy[3];
<a name="l02514"></a>02514 
<a name="l02515"></a>02515         vx[0]=x1;
<a name="l02516"></a>02516         vx[1]=x2;
<a name="l02517"></a>02517         vx[2]=x3;
<a name="l02518"></a>02518         vy[0]=y1;
<a name="l02519"></a>02519         vy[1]=y2;
<a name="l02520"></a>02520         vy[2]=y3;
<a name="l02521"></a>02521 
<a name="l02522"></a>02522         <span class="keywordflow">return</span>(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab66d826945d8994d9e17ee2745653cac" title="Draw filled polygon with alpha blending.">filledPolygonColor</a>(renderer,vx,vy,3,color));
<a name="l02523"></a>02523 }
<a name="l02524"></a>02524 
<a name="l02544"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a273cf4a88abf6c6a5e019b2c58ee2423">02544</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa828ac3c3fe5ce610c5ad1516dfb6f3f" title="Draw filled trigon (triangle) with alpha blending.">filledTrigonRGBA</a>(SDL_Renderer * renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
<a name="l02545"></a>02545         Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02546"></a>02546 {
<a name="l02547"></a>02547         Sint16 vx[3]; 
<a name="l02548"></a>02548         Sint16 vy[3];
<a name="l02549"></a>02549 
<a name="l02550"></a>02550         vx[0]=x1;
<a name="l02551"></a>02551         vx[1]=x2;
<a name="l02552"></a>02552         vx[2]=x3;
<a name="l02553"></a>02553         vy[0]=y1;
<a name="l02554"></a>02554         vy[1]=y2;
<a name="l02555"></a>02555         vy[2]=y3;
<a name="l02556"></a>02556 
<a name="l02557"></a>02557         <span class="keywordflow">return</span>(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a31ee2c3d19bd0e9ca5545b81269575a6" title="Draw filled polygon with alpha blending.">filledPolygonRGBA</a>(renderer,vx,vy,3,r,g,b,a));
<a name="l02558"></a>02558 }
<a name="l02559"></a>02559 
<a name="l02560"></a>02560 <span class="comment">/* ---- Polygon */</span>
<a name="l02561"></a>02561 
<a name="l02573"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a3577e5aee374d5176a3587343e11c4aa">02573</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a736477a8ea3068bcc3d8d9af4e07420e" title="Draw polygon with alpha blending.">polygonColor</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, Uint32 color)
<a name="l02574"></a>02574 {
<a name="l02575"></a>02575         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l02576"></a>02576         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#acf4c333418f95d250528c4106b6ead63" title="Draw polygon with alpha blending.">polygonRGBA</a>(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
<a name="l02577"></a>02577 }
<a name="l02578"></a>02578 
<a name="l02589"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a635ed8b4c7321f75d00938130edf2007">02589</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a635ed8b4c7321f75d00938130edf2007" title="Draw polygon with the currently set color and blend mode.">polygon</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n)
<a name="l02590"></a>02590 {
<a name="l02591"></a>02591         <span class="comment">/*</span>
<a name="l02592"></a>02592 <span class="comment">        * Draw </span>
<a name="l02593"></a>02593 <span class="comment">        */</span>
<a name="l02594"></a>02594         <span class="keywordtype">int</span> result;
<a name="l02595"></a>02595         <span class="keywordtype">int</span> i, nn;
<a name="l02596"></a>02596         SDL_Point* points;
<a name="l02597"></a>02597 
<a name="l02598"></a>02598         <span class="comment">/*</span>
<a name="l02599"></a>02599 <span class="comment">        * Vertex array NULL check </span>
<a name="l02600"></a>02600 <span class="comment">        */</span>
<a name="l02601"></a>02601         <span class="keywordflow">if</span> (vx == NULL) {
<a name="l02602"></a>02602                 <span class="keywordflow">return</span> (-1);
<a name="l02603"></a>02603         }
<a name="l02604"></a>02604         <span class="keywordflow">if</span> (vy == NULL) {
<a name="l02605"></a>02605                 <span class="keywordflow">return</span> (-1);
<a name="l02606"></a>02606         }
<a name="l02607"></a>02607 
<a name="l02608"></a>02608         <span class="comment">/*</span>
<a name="l02609"></a>02609 <span class="comment">        * Sanity check </span>
<a name="l02610"></a>02610 <span class="comment">        */</span>
<a name="l02611"></a>02611         <span class="keywordflow">if</span> (n &lt; 3) {
<a name="l02612"></a>02612                 <span class="keywordflow">return</span> (-1);
<a name="l02613"></a>02613         }
<a name="l02614"></a>02614 
<a name="l02615"></a>02615         <span class="comment">/*</span>
<a name="l02616"></a>02616 <span class="comment">        * Create array of points</span>
<a name="l02617"></a>02617 <span class="comment">        */</span>
<a name="l02618"></a>02618         nn = n + 1;
<a name="l02619"></a>02619         points = (SDL_Point*)malloc(<span class="keyword">sizeof</span>(SDL_Point) * nn);
<a name="l02620"></a>02620         <span class="keywordflow">if</span> (points == NULL)
<a name="l02621"></a>02621         {
<a name="l02622"></a>02622                 <span class="keywordflow">return</span> -1;
<a name="l02623"></a>02623         }
<a name="l02624"></a>02624         <span class="keywordflow">for</span> (i=0; i&lt;n; i++)
<a name="l02625"></a>02625         {
<a name="l02626"></a>02626                 points[i].x = vx[i];
<a name="l02627"></a>02627                 points[i].y = vy[i];
<a name="l02628"></a>02628         }
<a name="l02629"></a>02629         points[n].x = vx[0];
<a name="l02630"></a>02630         points[n].y = vy[0];
<a name="l02631"></a>02631 
<a name="l02632"></a>02632         <span class="comment">/*</span>
<a name="l02633"></a>02633 <span class="comment">        * Draw </span>
<a name="l02634"></a>02634 <span class="comment">        */</span>
<a name="l02635"></a>02635         result |= SDL_RenderDrawLines(renderer, points, nn);
<a name="l02636"></a>02636         free(points);
<a name="l02637"></a>02637 
<a name="l02638"></a>02638         <span class="keywordflow">return</span> (result);
<a name="l02639"></a>02639 }
<a name="l02640"></a>02640 
<a name="l02655"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a69baa68215840bb54ddd0281e6ad63a0">02655</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#acf4c333418f95d250528c4106b6ead63" title="Draw polygon with alpha blending.">polygonRGBA</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02656"></a>02656 {
<a name="l02657"></a>02657         <span class="comment">/*</span>
<a name="l02658"></a>02658 <span class="comment">        * Draw </span>
<a name="l02659"></a>02659 <span class="comment">        */</span>
<a name="l02660"></a>02660         <span class="keywordtype">int</span> result;
<a name="l02661"></a>02661         <span class="keyword">const</span> Sint16 *x1, *y1, *x2, *y2;
<a name="l02662"></a>02662 
<a name="l02663"></a>02663         <span class="comment">/*</span>
<a name="l02664"></a>02664 <span class="comment">        * Vertex array NULL check </span>
<a name="l02665"></a>02665 <span class="comment">        */</span>
<a name="l02666"></a>02666         <span class="keywordflow">if</span> (vx == NULL) {
<a name="l02667"></a>02667                 <span class="keywordflow">return</span> (-1);
<a name="l02668"></a>02668         }
<a name="l02669"></a>02669         <span class="keywordflow">if</span> (vy == NULL) {
<a name="l02670"></a>02670                 <span class="keywordflow">return</span> (-1);
<a name="l02671"></a>02671         }
<a name="l02672"></a>02672 
<a name="l02673"></a>02673         <span class="comment">/*</span>
<a name="l02674"></a>02674 <span class="comment">        * Sanity check </span>
<a name="l02675"></a>02675 <span class="comment">        */</span>
<a name="l02676"></a>02676         <span class="keywordflow">if</span> (n &lt; 3) {
<a name="l02677"></a>02677                 <span class="keywordflow">return</span> (-1);
<a name="l02678"></a>02678         }
<a name="l02679"></a>02679 
<a name="l02680"></a>02680         <span class="comment">/*</span>
<a name="l02681"></a>02681 <span class="comment">        * Pointer setup </span>
<a name="l02682"></a>02682 <span class="comment">        */</span>
<a name="l02683"></a>02683         x1 = x2 = vx;
<a name="l02684"></a>02684         y1 = y2 = vy;
<a name="l02685"></a>02685         x2++;
<a name="l02686"></a>02686         y2++;
<a name="l02687"></a>02687 
<a name="l02688"></a>02688         <span class="comment">/*</span>
<a name="l02689"></a>02689 <span class="comment">        * Set color </span>
<a name="l02690"></a>02690 <span class="comment">        */</span>
<a name="l02691"></a>02691         result = 0;
<a name="l02692"></a>02692         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l02693"></a>02693         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a); 
<a name="l02694"></a>02694 
<a name="l02695"></a>02695         <span class="comment">/*</span>
<a name="l02696"></a>02696 <span class="comment">        * Draw </span>
<a name="l02697"></a>02697 <span class="comment">        */</span>
<a name="l02698"></a>02698         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a635ed8b4c7321f75d00938130edf2007" title="Draw polygon with the currently set color and blend mode.">polygon</a>(renderer, vx, vy, n);
<a name="l02699"></a>02699 
<a name="l02700"></a>02700         <span class="keywordflow">return</span> (result);
<a name="l02701"></a>02701 }
<a name="l02702"></a>02702 
<a name="l02703"></a>02703 <span class="comment">/* ---- AA-Polygon */</span>
<a name="l02704"></a>02704 
<a name="l02716"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a54c28d1e469b52483e952258c2f6f69b">02716</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#adb4ea9b9394ef35410e1c4e164110f58" title="Draw anti-aliased polygon with alpha blending.">aapolygonColor</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, Uint32 color)
<a name="l02717"></a>02717 {
<a name="l02718"></a>02718         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l02719"></a>02719         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a431337e0736927d3bd5a0c53d1d6091a" title="Draw anti-aliased polygon with alpha blending.">aapolygonRGBA</a>(renderer, vx, vy, n, c[0], c[1], c[2], c[3]);
<a name="l02720"></a>02720 }
<a name="l02721"></a>02721 
<a name="l02736"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a6a18d7838305c636b8462e0ba587d859">02736</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a431337e0736927d3bd5a0c53d1d6091a" title="Draw anti-aliased polygon with alpha blending.">aapolygonRGBA</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l02737"></a>02737 {
<a name="l02738"></a>02738         <span class="keywordtype">int</span> result;
<a name="l02739"></a>02739         <span class="keywordtype">int</span> i;
<a name="l02740"></a>02740         <span class="keyword">const</span> Sint16 *x1, *y1, *x2, *y2;
<a name="l02741"></a>02741 
<a name="l02742"></a>02742         <span class="comment">/*</span>
<a name="l02743"></a>02743 <span class="comment">        * Vertex array NULL check </span>
<a name="l02744"></a>02744 <span class="comment">        */</span>
<a name="l02745"></a>02745         <span class="keywordflow">if</span> (vx == NULL) {
<a name="l02746"></a>02746                 <span class="keywordflow">return</span> (-1);
<a name="l02747"></a>02747         }
<a name="l02748"></a>02748         <span class="keywordflow">if</span> (vy == NULL) {
<a name="l02749"></a>02749                 <span class="keywordflow">return</span> (-1);
<a name="l02750"></a>02750         }
<a name="l02751"></a>02751 
<a name="l02752"></a>02752         <span class="comment">/*</span>
<a name="l02753"></a>02753 <span class="comment">        * Sanity check </span>
<a name="l02754"></a>02754 <span class="comment">        */</span>
<a name="l02755"></a>02755         <span class="keywordflow">if</span> (n &lt; 3) {
<a name="l02756"></a>02756                 <span class="keywordflow">return</span> (-1);
<a name="l02757"></a>02757         }
<a name="l02758"></a>02758 
<a name="l02759"></a>02759         <span class="comment">/*</span>
<a name="l02760"></a>02760 <span class="comment">        * Pointer setup </span>
<a name="l02761"></a>02761 <span class="comment">        */</span>
<a name="l02762"></a>02762         x1 = x2 = vx;
<a name="l02763"></a>02763         y1 = y2 = vy;
<a name="l02764"></a>02764         x2++;
<a name="l02765"></a>02765         y2++;
<a name="l02766"></a>02766 
<a name="l02767"></a>02767         <span class="comment">/*</span>
<a name="l02768"></a>02768 <span class="comment">        * Draw </span>
<a name="l02769"></a>02769 <span class="comment">        */</span>
<a name="l02770"></a>02770         result = 0;
<a name="l02771"></a>02771         <span class="keywordflow">for</span> (i = 1; i &lt; n; i++) {
<a name="l02772"></a>02772                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab9e0ea0234edece7549a1606829a4563" title="Internal function to draw anti-aliased line with alpha blending and endpoint control.">_aalineRGBA</a>(renderer, *x1, *y1, *x2, *y2, r, g, b, a, 0);
<a name="l02773"></a>02773                 x1 = x2;
<a name="l02774"></a>02774                 y1 = y2;
<a name="l02775"></a>02775                 x2++;
<a name="l02776"></a>02776                 y2++;
<a name="l02777"></a>02777         }
<a name="l02778"></a>02778 
<a name="l02779"></a>02779         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab9e0ea0234edece7549a1606829a4563" title="Internal function to draw anti-aliased line with alpha blending and endpoint control.">_aalineRGBA</a>(renderer, *x1, *y1, *vx, *vy, r, g, b, a, 0);
<a name="l02780"></a>02780 
<a name="l02781"></a>02781         <span class="keywordflow">return</span> (result);
<a name="l02782"></a>02782 }
<a name="l02783"></a>02783 
<a name="l02784"></a>02784 <span class="comment">/* ---- Filled Polygon */</span>
<a name="l02785"></a>02785 
<a name="l02794"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#aeba347cfe2561fdb7f86d995a941ff1a">02794</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aeba347cfe2561fdb7f86d995a941ff1a" title="Internal helper qsort callback functions used in filled polygon drawing.">_gfxPrimitivesCompareInt</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *a, <span class="keyword">const</span> <span class="keywordtype">void</span> *b)
<a name="l02795"></a>02795 {
<a name="l02796"></a>02796         <span class="keywordflow">return</span> (*(<span class="keyword">const</span> <span class="keywordtype">int</span> *) a) - (*(<span class="keyword">const</span> <span class="keywordtype">int</span> *) b);
<a name="l02797"></a>02797 }
<a name="l02798"></a>02798 
<a name="l02804"></a>02804 <span class="keyword">static</span> <span class="keywordtype">int</span> *gfxPrimitivesPolyIntsGlobal = NULL;
<a name="l02805"></a>02805 
<a name="l02811"></a>02811 <span class="keyword">static</span> <span class="keywordtype">int</span> gfxPrimitivesPolyAllocatedGlobal = 0;
<a name="l02812"></a>02812 
<a name="l02831"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a2bb1f089ab339cf7e4d873aaa677d7d6">02831</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a2bb1f089ab339cf7e4d873aaa677d7d6" title="Draw filled polygon with alpha blending (multi-threaded capable).">filledPolygonRGBAMT</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, Uint8 r, Uint8 g, Uint8 b, Uint8 a, <span class="keywordtype">int</span> **polyInts, <span class="keywordtype">int</span> *polyAllocated)
<a name="l02832"></a>02832 {
<a name="l02833"></a>02833         <span class="keywordtype">int</span> result;
<a name="l02834"></a>02834         <span class="keywordtype">int</span> i;
<a name="l02835"></a>02835         <span class="keywordtype">int</span> y, xa, xb;
<a name="l02836"></a>02836         <span class="keywordtype">int</span> miny, maxy;
<a name="l02837"></a>02837         <span class="keywordtype">int</span> x1, y1;
<a name="l02838"></a>02838         <span class="keywordtype">int</span> x2, y2;
<a name="l02839"></a>02839         <span class="keywordtype">int</span> ind1, ind2;
<a name="l02840"></a>02840         <span class="keywordtype">int</span> ints;
<a name="l02841"></a>02841         <span class="keywordtype">int</span> *gfxPrimitivesPolyInts = NULL;
<a name="l02842"></a>02842         <span class="keywordtype">int</span> *gfxPrimitivesPolyIntsNew = NULL;
<a name="l02843"></a>02843         <span class="keywordtype">int</span> gfxPrimitivesPolyAllocated = 0;
<a name="l02844"></a>02844 
<a name="l02845"></a>02845         <span class="comment">/*</span>
<a name="l02846"></a>02846 <span class="comment">        * Vertex array NULL check </span>
<a name="l02847"></a>02847 <span class="comment">        */</span>
<a name="l02848"></a>02848         <span class="keywordflow">if</span> (vx == NULL) {
<a name="l02849"></a>02849                 <span class="keywordflow">return</span> (-1);
<a name="l02850"></a>02850         }
<a name="l02851"></a>02851         <span class="keywordflow">if</span> (vy == NULL) {
<a name="l02852"></a>02852                 <span class="keywordflow">return</span> (-1);
<a name="l02853"></a>02853         }
<a name="l02854"></a>02854 
<a name="l02855"></a>02855         <span class="comment">/*</span>
<a name="l02856"></a>02856 <span class="comment">        * Sanity check number of edges</span>
<a name="l02857"></a>02857 <span class="comment">        */</span>
<a name="l02858"></a>02858         <span class="keywordflow">if</span> (n &lt; 3) {
<a name="l02859"></a>02859                 <span class="keywordflow">return</span> -1;
<a name="l02860"></a>02860         }
<a name="l02861"></a>02861 
<a name="l02862"></a>02862         <span class="comment">/*</span>
<a name="l02863"></a>02863 <span class="comment">        * Map polygon cache  </span>
<a name="l02864"></a>02864 <span class="comment">        */</span>
<a name="l02865"></a>02865         <span class="keywordflow">if</span> ((polyInts==NULL) || (polyAllocated==NULL)) {
<a name="l02866"></a>02866                 <span class="comment">/* Use global cache */</span>
<a name="l02867"></a>02867                 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
<a name="l02868"></a>02868                 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
<a name="l02869"></a>02869         } <span class="keywordflow">else</span> {
<a name="l02870"></a>02870                 <span class="comment">/* Use local cache */</span>
<a name="l02871"></a>02871                 gfxPrimitivesPolyInts = *polyInts;
<a name="l02872"></a>02872                 gfxPrimitivesPolyAllocated = *polyAllocated;
<a name="l02873"></a>02873         }
<a name="l02874"></a>02874 
<a name="l02875"></a>02875         <span class="comment">/*</span>
<a name="l02876"></a>02876 <span class="comment">        * Allocate temp array, only grow array </span>
<a name="l02877"></a>02877 <span class="comment">        */</span>
<a name="l02878"></a>02878         <span class="keywordflow">if</span> (!gfxPrimitivesPolyAllocated) {
<a name="l02879"></a>02879                 gfxPrimitivesPolyInts = (<span class="keywordtype">int</span> *) malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>) * n);
<a name="l02880"></a>02880                 gfxPrimitivesPolyAllocated = n;
<a name="l02881"></a>02881         } <span class="keywordflow">else</span> {
<a name="l02882"></a>02882                 <span class="keywordflow">if</span> (gfxPrimitivesPolyAllocated &lt; n) {
<a name="l02883"></a>02883                         gfxPrimitivesPolyIntsNew = (<span class="keywordtype">int</span> *) realloc(gfxPrimitivesPolyInts, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>) * n);
<a name="l02884"></a>02884                         <span class="keywordflow">if</span> (!gfxPrimitivesPolyIntsNew) {
<a name="l02885"></a>02885                                 <span class="keywordflow">if</span> (!gfxPrimitivesPolyInts) {
<a name="l02886"></a>02886                                         free(gfxPrimitivesPolyInts);
<a name="l02887"></a>02887                                         gfxPrimitivesPolyInts = NULL;
<a name="l02888"></a>02888                                 }
<a name="l02889"></a>02889                                 gfxPrimitivesPolyAllocated = 0;
<a name="l02890"></a>02890                         } <span class="keywordflow">else</span> {
<a name="l02891"></a>02891                                 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsNew;
<a name="l02892"></a>02892                                 gfxPrimitivesPolyAllocated = n;
<a name="l02893"></a>02893                         }
<a name="l02894"></a>02894                 }
<a name="l02895"></a>02895         }
<a name="l02896"></a>02896 
<a name="l02897"></a>02897         <span class="comment">/*</span>
<a name="l02898"></a>02898 <span class="comment">        * Check temp array</span>
<a name="l02899"></a>02899 <span class="comment">        */</span>
<a name="l02900"></a>02900         <span class="keywordflow">if</span> (gfxPrimitivesPolyInts==NULL) {        
<a name="l02901"></a>02901                 gfxPrimitivesPolyAllocated = 0;
<a name="l02902"></a>02902         }
<a name="l02903"></a>02903 
<a name="l02904"></a>02904         <span class="comment">/*</span>
<a name="l02905"></a>02905 <span class="comment">        * Update cache variables</span>
<a name="l02906"></a>02906 <span class="comment">        */</span>
<a name="l02907"></a>02907         <span class="keywordflow">if</span> ((polyInts==NULL) || (polyAllocated==NULL)) { 
<a name="l02908"></a>02908                 gfxPrimitivesPolyIntsGlobal =  gfxPrimitivesPolyInts;
<a name="l02909"></a>02909                 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
<a name="l02910"></a>02910         } <span class="keywordflow">else</span> {
<a name="l02911"></a>02911                 *polyInts = gfxPrimitivesPolyInts;
<a name="l02912"></a>02912                 *polyAllocated = gfxPrimitivesPolyAllocated;
<a name="l02913"></a>02913         }
<a name="l02914"></a>02914 
<a name="l02915"></a>02915         <span class="comment">/*</span>
<a name="l02916"></a>02916 <span class="comment">        * Check temp array again</span>
<a name="l02917"></a>02917 <span class="comment">        */</span>
<a name="l02918"></a>02918         <span class="keywordflow">if</span> (gfxPrimitivesPolyInts==NULL) {        
<a name="l02919"></a>02919                 <span class="keywordflow">return</span>(-1);
<a name="l02920"></a>02920         }
<a name="l02921"></a>02921 
<a name="l02922"></a>02922         <span class="comment">/*</span>
<a name="l02923"></a>02923 <span class="comment">        * Determine Y maxima </span>
<a name="l02924"></a>02924 <span class="comment">        */</span>
<a name="l02925"></a>02925         miny = vy[0];
<a name="l02926"></a>02926         maxy = vy[0];
<a name="l02927"></a>02927         <span class="keywordflow">for</span> (i = 1; (i &lt; n); i++) {
<a name="l02928"></a>02928                 <span class="keywordflow">if</span> (vy[i] &lt; miny) {
<a name="l02929"></a>02929                         miny = vy[i];
<a name="l02930"></a>02930                 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (vy[i] &gt; maxy) {
<a name="l02931"></a>02931                         maxy = vy[i];
<a name="l02932"></a>02932                 }
<a name="l02933"></a>02933         }
<a name="l02934"></a>02934 
<a name="l02935"></a>02935         <span class="comment">/*</span>
<a name="l02936"></a>02936 <span class="comment">        * Draw, scanning y </span>
<a name="l02937"></a>02937 <span class="comment">        */</span>
<a name="l02938"></a>02938         result = 0;
<a name="l02939"></a>02939         <span class="keywordflow">for</span> (y = miny; (y &lt;= maxy); y++) {
<a name="l02940"></a>02940                 ints = 0;
<a name="l02941"></a>02941                 <span class="keywordflow">for</span> (i = 0; (i &lt; n); i++) {
<a name="l02942"></a>02942                         <span class="keywordflow">if</span> (!i) {
<a name="l02943"></a>02943                                 ind1 = n - 1;
<a name="l02944"></a>02944                                 ind2 = 0;
<a name="l02945"></a>02945                         } <span class="keywordflow">else</span> {
<a name="l02946"></a>02946                                 ind1 = i - 1;
<a name="l02947"></a>02947                                 ind2 = i;
<a name="l02948"></a>02948                         }
<a name="l02949"></a>02949                         y1 = vy[ind1];
<a name="l02950"></a>02950                         y2 = vy[ind2];
<a name="l02951"></a>02951                         <span class="keywordflow">if</span> (y1 &lt; y2) {
<a name="l02952"></a>02952                                 x1 = vx[ind1];
<a name="l02953"></a>02953                                 x2 = vx[ind2];
<a name="l02954"></a>02954                         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (y1 &gt; y2) {
<a name="l02955"></a>02955                                 y2 = vy[ind1];
<a name="l02956"></a>02956                                 y1 = vy[ind2];
<a name="l02957"></a>02957                                 x2 = vx[ind1];
<a name="l02958"></a>02958                                 x1 = vx[ind2];
<a name="l02959"></a>02959                         } <span class="keywordflow">else</span> {
<a name="l02960"></a>02960                                 <span class="keywordflow">continue</span>;
<a name="l02961"></a>02961                         }
<a name="l02962"></a>02962                         <span class="keywordflow">if</span> ( ((y &gt;= y1) &amp;&amp; (y &lt; y2)) || ((y == maxy) &amp;&amp; (y &gt; y1) &amp;&amp; (y &lt;= y2)) ) {
<a name="l02963"></a>02963                                 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
<a name="l02964"></a>02964                         }           
<a name="l02965"></a>02965                 }
<a name="l02966"></a>02966 
<a name="l02967"></a>02967                 qsort(gfxPrimitivesPolyInts, ints, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aeba347cfe2561fdb7f86d995a941ff1a" title="Internal helper qsort callback functions used in filled polygon drawing.">_gfxPrimitivesCompareInt</a>);
<a name="l02968"></a>02968 
<a name="l02969"></a>02969                 <span class="comment">/*</span>
<a name="l02970"></a>02970 <span class="comment">                * Set color </span>
<a name="l02971"></a>02971 <span class="comment">                */</span>
<a name="l02972"></a>02972                 result = 0;
<a name="l02973"></a>02973             result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l02974"></a>02974                 result |= SDL_SetRenderDrawColor(renderer, r, g, b, a); 
<a name="l02975"></a>02975 
<a name="l02976"></a>02976                 <span class="keywordflow">for</span> (i = 0; (i &lt; ints); i += 2) {
<a name="l02977"></a>02977                         xa = gfxPrimitivesPolyInts[i] + 1;
<a name="l02978"></a>02978                         xa = (xa &gt;&gt; 16) + ((xa &amp; 32768) &gt;&gt; 15);
<a name="l02979"></a>02979                         xb = gfxPrimitivesPolyInts[i+1] - 1;
<a name="l02980"></a>02980                         xb = (xb &gt;&gt; 16) + ((xb &amp; 32768) &gt;&gt; 15);
<a name="l02981"></a>02981                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa73ac854afaeb66d6a33857aec8335f9" title="Draw horizontal line in currently set color.">hline</a>(renderer, xa, xb, y);
<a name="l02982"></a>02982                 }
<a name="l02983"></a>02983         }
<a name="l02984"></a>02984 
<a name="l02985"></a>02985         <span class="keywordflow">return</span> (result);
<a name="l02986"></a>02986 }
<a name="l02987"></a>02987 
<a name="l02999"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a97308e4f19363baee0e5bdecee3265f1">02999</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ab66d826945d8994d9e17ee2745653cac" title="Draw filled polygon with alpha blending.">filledPolygonColor</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, Uint32 color)
<a name="l03000"></a>03000 {
<a name="l03001"></a>03001         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l03002"></a>03002         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a2bb1f089ab339cf7e4d873aaa677d7d6" title="Draw filled polygon with alpha blending (multi-threaded capable).">filledPolygonRGBAMT</a>(renderer, vx, vy, n, c[0], c[1], c[2], c[3], NULL, NULL);
<a name="l03003"></a>03003 }
<a name="l03004"></a>03004 
<a name="l03019"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#ab80fe08abcf78a6ce8f037f3fdc15625">03019</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a31ee2c3d19bd0e9ca5545b81269575a6" title="Draw filled polygon with alpha blending.">filledPolygonRGBA</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l03020"></a>03020 {
<a name="l03021"></a>03021         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a2bb1f089ab339cf7e4d873aaa677d7d6" title="Draw filled polygon with alpha blending (multi-threaded capable).">filledPolygonRGBAMT</a>(renderer, vx, vy, n, r, g, b, a, NULL, NULL);
<a name="l03022"></a>03022 }
<a name="l03023"></a>03023 
<a name="l03024"></a>03024 <span class="comment">/* ---- Textured Polygon */</span>
<a name="l03025"></a>03025 
<a name="l03041"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a80bfea9271bbcf9e9655858bb58931c6">03041</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a80bfea9271bbcf9e9655858bb58931c6" title="Internal function to draw a textured horizontal line.">_HLineTextured</a>(SDL_Renderer *renderer, Sint16 x1, Sint16 x2, Sint16 y, SDL_Texture *texture, <span class="keywordtype">int</span> texture_w, <span class="keywordtype">int</span> texture_h, <span class="keywordtype">int</span> texture_dx, <span class="keywordtype">int</span> texture_dy)
<a name="l03042"></a>03042 {
<a name="l03043"></a>03043         Sint16 w;
<a name="l03044"></a>03044         Sint16 xtmp;
<a name="l03045"></a>03045         <span class="keywordtype">int</span> result = 0;
<a name="l03046"></a>03046         <span class="keywordtype">int</span> texture_x_walker;    
<a name="l03047"></a>03047         <span class="keywordtype">int</span> texture_y_start;    
<a name="l03048"></a>03048         SDL_Rect source_rect,dst_rect;
<a name="l03049"></a>03049         <span class="keywordtype">int</span> pixels_written,write_width;
<a name="l03050"></a>03050 
<a name="l03051"></a>03051         <span class="comment">/*</span>
<a name="l03052"></a>03052 <span class="comment">        * Swap x1, x2 if required to ensure x1&lt;=x2</span>
<a name="l03053"></a>03053 <span class="comment">        */</span>
<a name="l03054"></a>03054         <span class="keywordflow">if</span> (x1 &gt; x2) {
<a name="l03055"></a>03055                 xtmp = x1;
<a name="l03056"></a>03056                 x1 = x2;
<a name="l03057"></a>03057                 x2 = xtmp;
<a name="l03058"></a>03058         }
<a name="l03059"></a>03059 
<a name="l03060"></a>03060         <span class="comment">/*</span>
<a name="l03061"></a>03061 <span class="comment">        * Calculate width to draw</span>
<a name="l03062"></a>03062 <span class="comment">        */</span>
<a name="l03063"></a>03063         w = x2 - x1 + 1;
<a name="l03064"></a>03064 
<a name="l03065"></a>03065         <span class="comment">/*</span>
<a name="l03066"></a>03066 <span class="comment">        * Determine where in the texture we start drawing</span>
<a name="l03067"></a>03067 <span class="comment">        */</span>
<a name="l03068"></a>03068         texture_x_walker =   (x1 - texture_dx)  % texture_w;
<a name="l03069"></a>03069         <span class="keywordflow">if</span> (texture_x_walker &lt; 0){
<a name="l03070"></a>03070                 texture_x_walker = texture_w + texture_x_walker ;
<a name="l03071"></a>03071         }
<a name="l03072"></a>03072 
<a name="l03073"></a>03073         texture_y_start = (y + texture_dy) % texture_h;
<a name="l03074"></a>03074         <span class="keywordflow">if</span> (texture_y_start &lt; 0){
<a name="l03075"></a>03075                 texture_y_start = texture_h + texture_y_start;
<a name="l03076"></a>03076         }
<a name="l03077"></a>03077 
<a name="l03078"></a>03078         <span class="comment">// setup the source rectangle; we are only drawing one horizontal line</span>
<a name="l03079"></a>03079         source_rect.y = texture_y_start;
<a name="l03080"></a>03080         source_rect.x = texture_x_walker;
<a name="l03081"></a>03081         source_rect.h = 1;
<a name="l03082"></a>03082 
<a name="l03083"></a>03083         <span class="comment">// we will draw to the current y</span>
<a name="l03084"></a>03084         dst_rect.y = y;
<a name="l03085"></a>03085         dst_rect.h = 1;
<a name="l03086"></a>03086 
<a name="l03087"></a>03087         <span class="comment">// if there are enough pixels left in the current row of the texture</span>
<a name="l03088"></a>03088         <span class="comment">// draw it all at once</span>
<a name="l03089"></a>03089         <span class="keywordflow">if</span> (w &lt;= texture_w -texture_x_walker){
<a name="l03090"></a>03090                 source_rect.w = w;
<a name="l03091"></a>03091                 source_rect.x = texture_x_walker;
<a name="l03092"></a>03092                 dst_rect.x= x1;
<a name="l03093"></a>03093                 dst_rect.w = source_rect.w;
<a name="l03094"></a>03094                 result = (SDL_RenderCopy(renderer, texture, &amp;source_rect, &amp;dst_rect) == 0);
<a name="l03095"></a>03095         } <span class="keywordflow">else</span> { 
<a name="l03096"></a>03096                 <span class="comment">// we need to draw multiple times</span>
<a name="l03097"></a>03097                 <span class="comment">// draw the first segment</span>
<a name="l03098"></a>03098                 pixels_written = texture_w  - texture_x_walker;
<a name="l03099"></a>03099                 source_rect.w = pixels_written;
<a name="l03100"></a>03100                 source_rect.x = texture_x_walker;
<a name="l03101"></a>03101                 dst_rect.x= x1;
<a name="l03102"></a>03102                 dst_rect.w = source_rect.w;
<a name="l03103"></a>03103                 result |= (SDL_RenderCopy(renderer, texture, &amp;source_rect, &amp;dst_rect) == 0);
<a name="l03104"></a>03104                 write_width = texture_w;
<a name="l03105"></a>03105 
<a name="l03106"></a>03106                 <span class="comment">// now draw the rest</span>
<a name="l03107"></a>03107                 <span class="comment">// set the source x to 0</span>
<a name="l03108"></a>03108                 source_rect.x = 0;
<a name="l03109"></a>03109                 <span class="keywordflow">while</span> (pixels_written &lt; w){
<a name="l03110"></a>03110                         <span class="keywordflow">if</span> (write_width &gt;= w - pixels_written) {
<a name="l03111"></a>03111                                 write_width =  w - pixels_written;
<a name="l03112"></a>03112                         }
<a name="l03113"></a>03113                         source_rect.w = write_width;
<a name="l03114"></a>03114                         dst_rect.x = x1 + pixels_written;
<a name="l03115"></a>03115                         dst_rect.w = source_rect.w;
<a name="l03116"></a>03116                         result |= (SDL_RenderCopy(renderer, texture, &amp;source_rect, &amp;dst_rect) == 0);
<a name="l03117"></a>03117                         pixels_written += write_width;
<a name="l03118"></a>03118                 }
<a name="l03119"></a>03119         }
<a name="l03120"></a>03120 
<a name="l03121"></a>03121         <span class="keywordflow">return</span> result;
<a name="l03122"></a>03122 }
<a name="l03123"></a>03123 
<a name="l03140"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa28c0ceafacfeaede97d8ba5597ffe6e">03140</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa28c0ceafacfeaede97d8ba5597ffe6e" title="Draws a polygon filled with the given texture (Multi-Threading Capable).">texturedPolygonMT</a>(SDL_Renderer *renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, 
<a name="l03141"></a>03141         SDL_Surface * texture, <span class="keywordtype">int</span> texture_dx, <span class="keywordtype">int</span> texture_dy, <span class="keywordtype">int</span> **polyInts, <span class="keywordtype">int</span> *polyAllocated)
<a name="l03142"></a>03142 {
<a name="l03143"></a>03143         <span class="keywordtype">int</span> result;
<a name="l03144"></a>03144         <span class="keywordtype">int</span> i;
<a name="l03145"></a>03145         <span class="keywordtype">int</span> y, xa, xb;
<a name="l03146"></a>03146         <span class="keywordtype">int</span> minx,maxx,miny, maxy;
<a name="l03147"></a>03147         <span class="keywordtype">int</span> x1, y1;
<a name="l03148"></a>03148         <span class="keywordtype">int</span> x2, y2;
<a name="l03149"></a>03149         <span class="keywordtype">int</span> ind1, ind2;
<a name="l03150"></a>03150         <span class="keywordtype">int</span> ints;
<a name="l03151"></a>03151         <span class="keywordtype">int</span> *gfxPrimitivesPolyInts = NULL;
<a name="l03152"></a>03152         <span class="keywordtype">int</span> gfxPrimitivesPolyAllocated = 0;
<a name="l03153"></a>03153         SDL_Texture *textureAsTexture = NULL;
<a name="l03154"></a>03154 
<a name="l03155"></a>03155         <span class="comment">/*</span>
<a name="l03156"></a>03156 <span class="comment">        * Sanity check number of edges</span>
<a name="l03157"></a>03157 <span class="comment">        */</span>
<a name="l03158"></a>03158         <span class="keywordflow">if</span> (n &lt; 3) {
<a name="l03159"></a>03159                 <span class="keywordflow">return</span> -1;
<a name="l03160"></a>03160         }
<a name="l03161"></a>03161 
<a name="l03162"></a>03162         <span class="comment">/*</span>
<a name="l03163"></a>03163 <span class="comment">        * Map polygon cache  </span>
<a name="l03164"></a>03164 <span class="comment">        */</span>
<a name="l03165"></a>03165         <span class="keywordflow">if</span> ((polyInts==NULL) || (polyAllocated==NULL)) {
<a name="l03166"></a>03166                 <span class="comment">/* Use global cache */</span>
<a name="l03167"></a>03167                 gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
<a name="l03168"></a>03168                 gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
<a name="l03169"></a>03169         } <span class="keywordflow">else</span> {
<a name="l03170"></a>03170                 <span class="comment">/* Use local cache */</span>
<a name="l03171"></a>03171                 gfxPrimitivesPolyInts = *polyInts;
<a name="l03172"></a>03172                 gfxPrimitivesPolyAllocated = *polyAllocated;
<a name="l03173"></a>03173         }
<a name="l03174"></a>03174 
<a name="l03175"></a>03175         <span class="comment">/*</span>
<a name="l03176"></a>03176 <span class="comment">        * Allocate temp array, only grow array </span>
<a name="l03177"></a>03177 <span class="comment">        */</span>
<a name="l03178"></a>03178         <span class="keywordflow">if</span> (!gfxPrimitivesPolyAllocated) {
<a name="l03179"></a>03179                 gfxPrimitivesPolyInts = (<span class="keywordtype">int</span> *) malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">int</span>) * n);
<a name="l03180"></a>03180                 gfxPrimitivesPolyAllocated = n;
<a name="l03181"></a>03181         } <span class="keywordflow">else</span> {
<a name="l03182"></a>03182                 <span class="keywordflow">if</span> (gfxPrimitivesPolyAllocated &lt; n) {
<a name="l03183"></a>03183                         gfxPrimitivesPolyInts = (<span class="keywordtype">int</span> *) realloc(gfxPrimitivesPolyInts, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>) * n);
<a name="l03184"></a>03184                         gfxPrimitivesPolyAllocated = n;
<a name="l03185"></a>03185                 }
<a name="l03186"></a>03186         }
<a name="l03187"></a>03187 
<a name="l03188"></a>03188         <span class="comment">/*</span>
<a name="l03189"></a>03189 <span class="comment">        * Check temp array</span>
<a name="l03190"></a>03190 <span class="comment">        */</span>
<a name="l03191"></a>03191         <span class="keywordflow">if</span> (gfxPrimitivesPolyInts==NULL) {        
<a name="l03192"></a>03192                 gfxPrimitivesPolyAllocated = 0;
<a name="l03193"></a>03193         }
<a name="l03194"></a>03194 
<a name="l03195"></a>03195         <span class="comment">/*</span>
<a name="l03196"></a>03196 <span class="comment">        * Update cache variables</span>
<a name="l03197"></a>03197 <span class="comment">        */</span>
<a name="l03198"></a>03198         <span class="keywordflow">if</span> ((polyInts==NULL) || (polyAllocated==NULL)) { 
<a name="l03199"></a>03199                 gfxPrimitivesPolyIntsGlobal =  gfxPrimitivesPolyInts;
<a name="l03200"></a>03200                 gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
<a name="l03201"></a>03201         } <span class="keywordflow">else</span> {
<a name="l03202"></a>03202                 *polyInts = gfxPrimitivesPolyInts;
<a name="l03203"></a>03203                 *polyAllocated = gfxPrimitivesPolyAllocated;
<a name="l03204"></a>03204         }
<a name="l03205"></a>03205 
<a name="l03206"></a>03206         <span class="comment">/*</span>
<a name="l03207"></a>03207 <span class="comment">        * Check temp array again</span>
<a name="l03208"></a>03208 <span class="comment">        */</span>
<a name="l03209"></a>03209         <span class="keywordflow">if</span> (gfxPrimitivesPolyInts==NULL) {        
<a name="l03210"></a>03210                 <span class="keywordflow">return</span>(-1);
<a name="l03211"></a>03211         }
<a name="l03212"></a>03212 
<a name="l03213"></a>03213         <span class="comment">/*</span>
<a name="l03214"></a>03214 <span class="comment">        * Determine X,Y minima,maxima </span>
<a name="l03215"></a>03215 <span class="comment">        */</span>
<a name="l03216"></a>03216         miny = vy[0];
<a name="l03217"></a>03217         maxy = vy[0];
<a name="l03218"></a>03218         minx = vx[0];
<a name="l03219"></a>03219         maxx = vx[0];
<a name="l03220"></a>03220         <span class="keywordflow">for</span> (i = 1; (i &lt; n); i++) {
<a name="l03221"></a>03221                 <span class="keywordflow">if</span> (vy[i] &lt; miny) {
<a name="l03222"></a>03222                         miny = vy[i];
<a name="l03223"></a>03223                 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (vy[i] &gt; maxy) {
<a name="l03224"></a>03224                         maxy = vy[i];
<a name="l03225"></a>03225                 }
<a name="l03226"></a>03226                 <span class="keywordflow">if</span> (vx[i] &lt; minx) {
<a name="l03227"></a>03227                         minx = vx[i];
<a name="l03228"></a>03228                 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (vx[i] &gt; maxx) {
<a name="l03229"></a>03229                         maxx = vx[i];
<a name="l03230"></a>03230                 }
<a name="l03231"></a>03231         }
<a name="l03232"></a>03232 
<a name="l03233"></a>03233     <span class="comment">/* Create texture for drawing */</span>
<a name="l03234"></a>03234         textureAsTexture = SDL_CreateTextureFromSurface(renderer, texture);
<a name="l03235"></a>03235         <span class="keywordflow">if</span> (textureAsTexture == NULL)
<a name="l03236"></a>03236         {
<a name="l03237"></a>03237                 <span class="keywordflow">return</span> -1;
<a name="l03238"></a>03238         }
<a name="l03239"></a>03239         SDL_SetTextureBlendMode(textureAsTexture, SDL_BLENDMODE_BLEND);
<a name="l03240"></a>03240         
<a name="l03241"></a>03241         <span class="comment">/*</span>
<a name="l03242"></a>03242 <span class="comment">        * Draw, scanning y </span>
<a name="l03243"></a>03243 <span class="comment">        */</span>
<a name="l03244"></a>03244         result = 0;
<a name="l03245"></a>03245         <span class="keywordflow">for</span> (y = miny; (y &lt;= maxy); y++) {
<a name="l03246"></a>03246                 ints = 0;
<a name="l03247"></a>03247                 <span class="keywordflow">for</span> (i = 0; (i &lt; n); i++) {
<a name="l03248"></a>03248                         <span class="keywordflow">if</span> (!i) {
<a name="l03249"></a>03249                                 ind1 = n - 1;
<a name="l03250"></a>03250                                 ind2 = 0;
<a name="l03251"></a>03251                         } <span class="keywordflow">else</span> {
<a name="l03252"></a>03252                                 ind1 = i - 1;
<a name="l03253"></a>03253                                 ind2 = i;
<a name="l03254"></a>03254                         }
<a name="l03255"></a>03255                         y1 = vy[ind1];
<a name="l03256"></a>03256                         y2 = vy[ind2];
<a name="l03257"></a>03257                         <span class="keywordflow">if</span> (y1 &lt; y2) {
<a name="l03258"></a>03258                                 x1 = vx[ind1];
<a name="l03259"></a>03259                                 x2 = vx[ind2];
<a name="l03260"></a>03260                         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (y1 &gt; y2) {
<a name="l03261"></a>03261                                 y2 = vy[ind1];
<a name="l03262"></a>03262                                 y1 = vy[ind2];
<a name="l03263"></a>03263                                 x2 = vx[ind1];
<a name="l03264"></a>03264                                 x1 = vx[ind2];
<a name="l03265"></a>03265                         } <span class="keywordflow">else</span> {
<a name="l03266"></a>03266                                 <span class="keywordflow">continue</span>;
<a name="l03267"></a>03267                         }
<a name="l03268"></a>03268                         <span class="keywordflow">if</span> ( ((y &gt;= y1) &amp;&amp; (y &lt; y2)) || ((y == maxy) &amp;&amp; (y &gt; y1) &amp;&amp; (y &lt;= y2)) ) {
<a name="l03269"></a>03269                                 gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
<a name="l03270"></a>03270                         } 
<a name="l03271"></a>03271                 }
<a name="l03272"></a>03272 
<a name="l03273"></a>03273                 qsort(gfxPrimitivesPolyInts, ints, <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aeba347cfe2561fdb7f86d995a941ff1a" title="Internal helper qsort callback functions used in filled polygon drawing.">_gfxPrimitivesCompareInt</a>);
<a name="l03274"></a>03274 
<a name="l03275"></a>03275                 <span class="keywordflow">for</span> (i = 0; (i &lt; ints); i += 2) {
<a name="l03276"></a>03276                         xa = gfxPrimitivesPolyInts[i] + 1;
<a name="l03277"></a>03277                         xa = (xa &gt;&gt; 16) + ((xa &amp; 32768) &gt;&gt; 15);
<a name="l03278"></a>03278                         xb = gfxPrimitivesPolyInts[i+1] - 1;
<a name="l03279"></a>03279                         xb = (xb &gt;&gt; 16) + ((xb &amp; 32768) &gt;&gt; 15);
<a name="l03280"></a>03280                         result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a80bfea9271bbcf9e9655858bb58931c6" title="Internal function to draw a textured horizontal line.">_HLineTextured</a>(renderer, xa, xb, y, textureAsTexture, texture-&gt;w, texture-&gt;h, texture_dx, texture_dy);
<a name="l03281"></a>03281                 }
<a name="l03282"></a>03282         }
<a name="l03283"></a>03283 
<a name="l03284"></a>03284         SDL_RenderPresent(renderer);
<a name="l03285"></a>03285         SDL_DestroyTexture(textureAsTexture);
<a name="l03286"></a>03286 
<a name="l03287"></a>03287         <span class="keywordflow">return</span> (result);
<a name="l03288"></a>03288 }
<a name="l03289"></a>03289 
<a name="l03306"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a3b4c81592098da506f534d4a81b266f2">03306</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a2ca947a90a81d4a2b778a7489edbedee" title="Draws a polygon filled with the given texture.">texturedPolygon</a>(SDL_Renderer *renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, SDL_Surface *texture, <span class="keywordtype">int</span> texture_dx, <span class="keywordtype">int</span> texture_dy)
<a name="l03307"></a>03307 {
<a name="l03308"></a>03308         <span class="comment">/*</span>
<a name="l03309"></a>03309 <span class="comment">        * Draw</span>
<a name="l03310"></a>03310 <span class="comment">        */</span>
<a name="l03311"></a>03311         <span class="keywordflow">return</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa28c0ceafacfeaede97d8ba5597ffe6e" title="Draws a polygon filled with the given texture (Multi-Threading Capable).">texturedPolygonMT</a>(renderer, vx, vy, n, texture, texture_dx, texture_dy, NULL, NULL));
<a name="l03312"></a>03312 }
<a name="l03313"></a>03313 
<a name="l03314"></a>03314 <span class="comment">/* ---- Character */</span>
<a name="l03315"></a>03315 
<a name="l03319"></a>03319 <span class="keyword">static</span> SDL_Texture *gfxPrimitivesFont[256];
<a name="l03320"></a>03320 
<a name="l03324"></a>03324 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *currentFontdata = gfxPrimitivesFontdata;
<a name="l03325"></a>03325 
<a name="l03329"></a>03329 <span class="keyword">static</span> Uint32 charWidth = 8;
<a name="l03330"></a>03330 
<a name="l03334"></a>03334 <span class="keyword">static</span> Uint32 charHeight = 8;
<a name="l03335"></a>03335 
<a name="l03339"></a>03339 <span class="keyword">static</span> Uint32 charWidthLocal = 8;
<a name="l03340"></a>03340 
<a name="l03344"></a>03344 <span class="keyword">static</span> Uint32 charHeightLocal = 8;
<a name="l03345"></a>03345 
<a name="l03349"></a>03349 <span class="keyword">static</span> Uint32 charPitch = 1;
<a name="l03350"></a>03350 
<a name="l03354"></a>03354 <span class="keyword">static</span> Uint32 charRotation = 0;
<a name="l03355"></a>03355 
<a name="l03359"></a>03359 <span class="keyword">static</span> Uint32 charSize = 8;
<a name="l03360"></a>03360 
<a name="l03374"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#adcbe6b74a9e0fef4165bc7bdb73294ec">03374</a> <span class="keywordtype">void</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#afacd57651ec0e0ccab60753636862cd0" title="Sets or resets the current global font data.">gfxPrimitivesSetFont</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *fontdata, Uint32 cw, Uint32 ch)
<a name="l03375"></a>03375 {
<a name="l03376"></a>03376         <span class="keywordtype">int</span> i;
<a name="l03377"></a>03377 
<a name="l03378"></a>03378         <span class="keywordflow">if</span> ((fontdata) &amp;&amp; (cw) &amp;&amp; (ch)) {
<a name="l03379"></a>03379                 currentFontdata = (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)fontdata;
<a name="l03380"></a>03380                 charWidth = cw;
<a name="l03381"></a>03381                 charHeight = ch;
<a name="l03382"></a>03382         } <span class="keywordflow">else</span> {
<a name="l03383"></a>03383                 currentFontdata = gfxPrimitivesFontdata;
<a name="l03384"></a>03384                 charWidth = 8;
<a name="l03385"></a>03385                 charHeight = 8;
<a name="l03386"></a>03386         }
<a name="l03387"></a>03387 
<a name="l03388"></a>03388         charPitch = (charWidth+7)/8;
<a name="l03389"></a>03389         charSize = charPitch * charHeight;
<a name="l03390"></a>03390 
<a name="l03391"></a>03391         <span class="comment">/* Maybe flip width/height for rendering */</span>
<a name="l03392"></a>03392         <span class="keywordflow">if</span> ((charRotation==1) || (charRotation==3))
<a name="l03393"></a>03393         {
<a name="l03394"></a>03394                 charWidthLocal = charHeight;
<a name="l03395"></a>03395                 charHeightLocal = charWidth;
<a name="l03396"></a>03396         }
<a name="l03397"></a>03397         <span class="keywordflow">else</span>
<a name="l03398"></a>03398         {
<a name="l03399"></a>03399                 charWidthLocal = charWidth;
<a name="l03400"></a>03400                 charHeightLocal = charHeight;
<a name="l03401"></a>03401         }
<a name="l03402"></a>03402 
<a name="l03403"></a>03403         <span class="comment">/* Clear character cache */</span>
<a name="l03404"></a>03404         <span class="keywordflow">for</span> (i = 0; i &lt; 256; i++) {
<a name="l03405"></a>03405                 <span class="keywordflow">if</span> (gfxPrimitivesFont[i]) {
<a name="l03406"></a>03406                         SDL_DestroyTexture(gfxPrimitivesFont[i]);
<a name="l03407"></a>03407                         gfxPrimitivesFont[i] = NULL;
<a name="l03408"></a>03408                 }
<a name="l03409"></a>03409         }
<a name="l03410"></a>03410 }
<a name="l03411"></a>03411 
<a name="l03420"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a2349bb02995a364f6b1069c46a09b7ba">03420</a> <span class="keywordtype">void</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aef6796a883f07d31bbf7c7df6d1153d2" title="Sets current global font character rotation steps.">gfxPrimitivesSetFontRotation</a>(Uint32 rotation)
<a name="l03421"></a>03421 {
<a name="l03422"></a>03422         <span class="keywordtype">int</span> i;
<a name="l03423"></a>03423 
<a name="l03424"></a>03424         rotation = rotation &amp; 3;
<a name="l03425"></a>03425         <span class="keywordflow">if</span> (charRotation != rotation)
<a name="l03426"></a>03426         {
<a name="l03427"></a>03427                 <span class="comment">/* Store rotation */</span>
<a name="l03428"></a>03428                 charRotation = rotation;
<a name="l03429"></a>03429 
<a name="l03430"></a>03430                 <span class="comment">/* Maybe flip width/height for rendering */</span>
<a name="l03431"></a>03431                 <span class="keywordflow">if</span> ((charRotation==1) || (charRotation==3))
<a name="l03432"></a>03432                 {
<a name="l03433"></a>03433                         charWidthLocal = charHeight;
<a name="l03434"></a>03434                         charHeightLocal = charWidth;
<a name="l03435"></a>03435                 }
<a name="l03436"></a>03436                 <span class="keywordflow">else</span>
<a name="l03437"></a>03437                 {
<a name="l03438"></a>03438                         charWidthLocal = charWidth;
<a name="l03439"></a>03439                         charHeightLocal = charHeight;
<a name="l03440"></a>03440                 }
<a name="l03441"></a>03441 
<a name="l03442"></a>03442                 <span class="comment">/* Clear character cache */</span>
<a name="l03443"></a>03443                 <span class="keywordflow">for</span> (i = 0; i &lt; 256; i++) {
<a name="l03444"></a>03444                         <span class="keywordflow">if</span> (gfxPrimitivesFont[i]) {
<a name="l03445"></a>03445                                 SDL_DestroyTexture(gfxPrimitivesFont[i]);
<a name="l03446"></a>03446                                 gfxPrimitivesFont[i] = NULL;
<a name="l03447"></a>03447                         }
<a name="l03448"></a>03448                 }
<a name="l03449"></a>03449         }
<a name="l03450"></a>03450 }
<a name="l03451"></a>03451 
<a name="l03466"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#abff6cc81b9a35e9380e0b02da905714f">03466</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa2edfd8d352bd6483d219ac3c36254f9" title="Draw a character of the currently set font.">characterRGBA</a>(SDL_Renderer *renderer, Sint16 x, Sint16 y, <span class="keywordtype">char</span> c, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l03467"></a>03467 {
<a name="l03468"></a>03468         SDL_Rect srect;
<a name="l03469"></a>03469         SDL_Rect drect;
<a name="l03470"></a>03470         <span class="keywordtype">int</span> result;
<a name="l03471"></a>03471         Uint32 ix, iy;
<a name="l03472"></a>03472         <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *charpos;
<a name="l03473"></a>03473         Uint8 *curpos;
<a name="l03474"></a>03474         Uint8 patt, mask;
<a name="l03475"></a>03475         Uint8 *linepos;
<a name="l03476"></a>03476         Uint32 pitch;
<a name="l03477"></a>03477         SDL_Surface *character;
<a name="l03478"></a>03478         SDL_Surface *rotatedCharacter;
<a name="l03479"></a>03479         Uint32 ci;
<a name="l03480"></a>03480 
<a name="l03481"></a>03481         <span class="comment">/*</span>
<a name="l03482"></a>03482 <span class="comment">        * Setup source rectangle</span>
<a name="l03483"></a>03483 <span class="comment">        */</span>
<a name="l03484"></a>03484         srect.x = 0;
<a name="l03485"></a>03485         srect.y = 0;
<a name="l03486"></a>03486         srect.w = charWidthLocal;
<a name="l03487"></a>03487         srect.h = charHeightLocal;
<a name="l03488"></a>03488 
<a name="l03489"></a>03489         <span class="comment">/*</span>
<a name="l03490"></a>03490 <span class="comment">        * Setup destination rectangle</span>
<a name="l03491"></a>03491 <span class="comment">        */</span>
<a name="l03492"></a>03492         drect.x = x;
<a name="l03493"></a>03493         drect.y = y;
<a name="l03494"></a>03494         drect.w = charWidthLocal;
<a name="l03495"></a>03495         drect.h = charHeightLocal;
<a name="l03496"></a>03496 
<a name="l03497"></a>03497         <span class="comment">/* Character index in cache */</span>
<a name="l03498"></a>03498         ci = (<span class="keywordtype">unsigned</span> char) c;
<a name="l03499"></a>03499 
<a name="l03500"></a>03500         <span class="comment">/*</span>
<a name="l03501"></a>03501 <span class="comment">        * Create new charWidth x charHeight bitmap surface if not already present.</span>
<a name="l03502"></a>03502 <span class="comment">        * Might get rotated later.</span>
<a name="l03503"></a>03503 <span class="comment">        */</span>
<a name="l03504"></a>03504         <span class="keywordflow">if</span> (gfxPrimitivesFont[ci] == NULL) {
<a name="l03505"></a>03505                 <span class="comment">/*</span>
<a name="l03506"></a>03506 <span class="comment">                * Redraw character into surface</span>
<a name="l03507"></a>03507 <span class="comment">                */</span>
<a name="l03508"></a>03508                 character =     SDL_CreateRGBSurface(SDL_SWSURFACE,
<a name="l03509"></a>03509                         charWidth, charHeight, 32,
<a name="l03510"></a>03510                         0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
<a name="l03511"></a>03511                 <span class="keywordflow">if</span> (character == NULL) {
<a name="l03512"></a>03512                         <span class="keywordflow">return</span> (-1);
<a name="l03513"></a>03513                 }
<a name="l03514"></a>03514 
<a name="l03515"></a>03515                 charpos = currentFontdata + ci * charSize;
<a name="l03516"></a>03516                                 linepos = (Uint8 *)character-&gt;pixels;
<a name="l03517"></a>03517                 pitch = character-&gt;pitch;
<a name="l03518"></a>03518 
<a name="l03519"></a>03519                 <span class="comment">/*</span>
<a name="l03520"></a>03520 <span class="comment">                * Drawing loop </span>
<a name="l03521"></a>03521 <span class="comment">                */</span>
<a name="l03522"></a>03522                 patt = 0;
<a name="l03523"></a>03523                 for (iy = 0; iy &lt; charHeight; iy++) {
<a name="l03524"></a>03524                         mask = 0x00;
<a name="l03525"></a>03525                         curpos = linepos;
<a name="l03526"></a>03526                         <span class="keywordflow">for</span> (ix = 0; ix &lt; charWidth; ix++) {
<a name="l03527"></a>03527                                 <span class="keywordflow">if</span> (!(mask &gt;&gt;= 1)) {
<a name="l03528"></a>03528                                         patt = *charpos++;
<a name="l03529"></a>03529                                         mask = 0x80;
<a name="l03530"></a>03530                                 }
<a name="l03531"></a>03531                                 <span class="keywordflow">if</span> (patt &amp; mask) {
<a name="l03532"></a>03532                                         *(Uint32 *)curpos = 0xffffffff;
<a name="l03533"></a>03533                                 } <span class="keywordflow">else</span> {
<a name="l03534"></a>03534                                         *(Uint32 *)curpos = 0;
<a name="l03535"></a>03535                                 }
<a name="l03536"></a>03536                                 curpos += 4;
<a name="l03537"></a>03537                         }
<a name="l03538"></a>03538                         linepos += pitch;
<a name="l03539"></a>03539                 }
<a name="l03540"></a>03540 
<a name="l03541"></a>03541                 <span class="comment">/* Maybe rotate and replace cached image */</span>
<a name="l03542"></a>03542                 <span class="keywordflow">if</span> (charRotation&gt;0)
<a name="l03543"></a>03543                 {
<a name="l03544"></a>03544                         rotatedCharacter = <a class="code" href="_s_d_l2__rotozoom_8c.html#a77563d68634cb2624d4f2f0bcdc19e73" title="Rotates a 8/16/24/32 bit surface in increments of 90 degrees.">rotateSurface90Degrees</a>(character, charRotation);
<a name="l03545"></a>03545                         SDL_FreeSurface(character);
<a name="l03546"></a>03546                         character = rotatedCharacter;
<a name="l03547"></a>03547                 }
<a name="l03548"></a>03548 
<a name="l03549"></a>03549                 <span class="comment">/* Convert temp surface into texture */</span>
<a name="l03550"></a>03550                 gfxPrimitivesFont[ci] = SDL_CreateTextureFromSurface(renderer, character);
<a name="l03551"></a>03551                 SDL_FreeSurface(character);
<a name="l03552"></a>03552 
<a name="l03553"></a>03553                 <span class="comment">/*</span>
<a name="l03554"></a>03554 <span class="comment">                * Check pointer </span>
<a name="l03555"></a>03555 <span class="comment">                */</span>
<a name="l03556"></a>03556                 <span class="keywordflow">if</span> (gfxPrimitivesFont[ci] == NULL) {
<a name="l03557"></a>03557                         <span class="keywordflow">return</span> (-1);
<a name="l03558"></a>03558                 }
<a name="l03559"></a>03559         }
<a name="l03560"></a>03560 
<a name="l03561"></a>03561         <span class="comment">/*</span>
<a name="l03562"></a>03562 <span class="comment">        * Set color </span>
<a name="l03563"></a>03563 <span class="comment">        */</span>
<a name="l03564"></a>03564         result = 0;
<a name="l03565"></a>03565         result |= SDL_SetTextureColorMod(gfxPrimitivesFont[ci], r, g, b);
<a name="l03566"></a>03566         result |= SDL_SetTextureAlphaMod(gfxPrimitivesFont[ci], a);
<a name="l03567"></a>03567 
<a name="l03568"></a>03568         <span class="comment">/*</span>
<a name="l03569"></a>03569 <span class="comment">        * Draw texture onto destination </span>
<a name="l03570"></a>03570 <span class="comment">        */</span>
<a name="l03571"></a>03571         result |= SDL_RenderCopy(renderer, gfxPrimitivesFont[ci], &amp;srect, &amp;drect);
<a name="l03572"></a>03572 
<a name="l03573"></a>03573         <span class="keywordflow">return</span> (result);
<a name="l03574"></a>03574 }
<a name="l03575"></a>03575 
<a name="l03576"></a>03576 
<a name="l03588"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#aaeed3ccb288e032856cff488bdba381d">03588</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a9856e3c1366ebd9749809417786a6ed7" title="Draw a character of the currently set font.">characterColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, <span class="keywordtype">char</span> c, Uint32 color)
<a name="l03589"></a>03589 {
<a name="l03590"></a>03590         Uint8 *co = (Uint8 *)&amp;color; 
<a name="l03591"></a>03591         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa2edfd8d352bd6483d219ac3c36254f9" title="Draw a character of the currently set font.">characterRGBA</a>(renderer, x, y, c, co[0], co[1], co[2], co[3]);
<a name="l03592"></a>03592 }
<a name="l03593"></a>03593 
<a name="l03594"></a>03594 
<a name="l03609"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a329e9c81b07e5af08d73e3b3d6078bf0">03609</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a123f0b72cbdc48e4d47c2942043819a9" title="Draw a string in the currently set font.">stringColor</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, <span class="keyword">const</span> <span class="keywordtype">char</span> *s, Uint32 color)
<a name="l03610"></a>03610 {
<a name="l03611"></a>03611         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l03612"></a>03612         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a22b256fbc6a186b98ec6674c1d781c2f" title="Draw a string in the currently set font.">stringRGBA</a>(renderer, x, y, s, c[0], c[1], c[2], c[3]);
<a name="l03613"></a>03613 }
<a name="l03614"></a>03614 
<a name="l03629"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a744afe14139c1c553204a47cc284e478">03629</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a22b256fbc6a186b98ec6674c1d781c2f" title="Draw a string in the currently set font.">stringRGBA</a>(SDL_Renderer * renderer, Sint16 x, Sint16 y, <span class="keyword">const</span> <span class="keywordtype">char</span> *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l03630"></a>03630 {
<a name="l03631"></a>03631         <span class="keywordtype">int</span> result = 0;
<a name="l03632"></a>03632         Sint16 curx = x;
<a name="l03633"></a>03633         Sint16 cury = y;
<a name="l03634"></a>03634         <span class="keyword">const</span> <span class="keywordtype">char</span> *curchar = s;
<a name="l03635"></a>03635 
<a name="l03636"></a>03636         <span class="keywordflow">while</span> (*curchar &amp;&amp; !result) {
<a name="l03637"></a>03637                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aa2edfd8d352bd6483d219ac3c36254f9" title="Draw a character of the currently set font.">characterRGBA</a>(renderer, curx, cury, *curchar, r, g, b, a);
<a name="l03638"></a>03638                 <span class="keywordflow">switch</span> (charRotation)
<a name="l03639"></a>03639                 {
<a name="l03640"></a>03640                 <span class="keywordflow">case</span> 0:
<a name="l03641"></a>03641                         curx += charWidthLocal;
<a name="l03642"></a>03642                         <span class="keywordflow">break</span>;
<a name="l03643"></a>03643                 <span class="keywordflow">case</span> 2:
<a name="l03644"></a>03644                         curx -= charWidthLocal;
<a name="l03645"></a>03645                         <span class="keywordflow">break</span>;
<a name="l03646"></a>03646                 <span class="keywordflow">case</span> 1:
<a name="l03647"></a>03647                         cury += charHeightLocal;
<a name="l03648"></a>03648                         <span class="keywordflow">break</span>;
<a name="l03649"></a>03649                 <span class="keywordflow">case</span> 3:
<a name="l03650"></a>03650                         cury -= charHeightLocal;
<a name="l03651"></a>03651                         <span class="keywordflow">break</span>;
<a name="l03652"></a>03652                 }
<a name="l03653"></a>03653                 curchar++;
<a name="l03654"></a>03654         }
<a name="l03655"></a>03655 
<a name="l03656"></a>03656         <span class="keywordflow">return</span> (result);
<a name="l03657"></a>03657 }
<a name="l03658"></a>03658 
<a name="l03659"></a>03659 <span class="comment">/* ---- Bezier curve */</span>
<a name="l03660"></a>03660 
<a name="l03670"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a888411ec724ddb9ff19cf9ba9fc067df">03670</a> <span class="keywordtype">double</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a888411ec724ddb9ff19cf9ba9fc067df" title="Internal function to calculate bezier interpolator of data array with ndata values at position &#39;t&#39;...">_evaluateBezier</a> (<span class="keywordtype">double</span> *data, <span class="keywordtype">int</span> ndata, <span class="keywordtype">double</span> t) 
<a name="l03671"></a>03671 {
<a name="l03672"></a>03672         <span class="keywordtype">double</span> mu, result;
<a name="l03673"></a>03673         <span class="keywordtype">int</span> n,k,kn,nn,nkn;
<a name="l03674"></a>03674         <span class="keywordtype">double</span> blend,muk,munk;
<a name="l03675"></a>03675 
<a name="l03676"></a>03676         <span class="comment">/* Sanity check bounds */</span>
<a name="l03677"></a>03677         <span class="keywordflow">if</span> (t&lt;0.0) {
<a name="l03678"></a>03678                 <span class="keywordflow">return</span>(data[0]);
<a name="l03679"></a>03679         }
<a name="l03680"></a>03680         <span class="keywordflow">if</span> (t&gt;=(<span class="keywordtype">double</span>)ndata) {
<a name="l03681"></a>03681                 <span class="keywordflow">return</span>(data[ndata-1]);
<a name="l03682"></a>03682         }
<a name="l03683"></a>03683 
<a name="l03684"></a>03684         <span class="comment">/* Adjust t to the range 0.0 to 1.0 */</span> 
<a name="l03685"></a>03685         mu=t/(double)ndata;
<a name="l03686"></a>03686 
<a name="l03687"></a>03687         <span class="comment">/* Calculate interpolate */</span>
<a name="l03688"></a>03688         n=ndata-1;
<a name="l03689"></a>03689         result=0.0;
<a name="l03690"></a>03690         muk = 1;
<a name="l03691"></a>03691         munk = pow(1-mu,(<span class="keywordtype">double</span>)n);
<a name="l03692"></a>03692         <span class="keywordflow">for</span> (k=0;k&lt;=n;k++) {
<a name="l03693"></a>03693                 nn = n;
<a name="l03694"></a>03694                 kn = k;
<a name="l03695"></a>03695                 nkn = n - k;
<a name="l03696"></a>03696                 blend = muk * munk;
<a name="l03697"></a>03697                 muk *= mu;
<a name="l03698"></a>03698                 munk /= (1-mu);
<a name="l03699"></a>03699                 <span class="keywordflow">while</span> (nn &gt;= 1) {
<a name="l03700"></a>03700                         blend *= nn;
<a name="l03701"></a>03701                         nn--;
<a name="l03702"></a>03702                         <span class="keywordflow">if</span> (kn &gt; 1) {
<a name="l03703"></a>03703                                 blend /= (double)kn;
<a name="l03704"></a>03704                                 kn--;
<a name="l03705"></a>03705                         }
<a name="l03706"></a>03706                         <span class="keywordflow">if</span> (nkn &gt; 1) {
<a name="l03707"></a>03707                                 blend /= (double)nkn;
<a name="l03708"></a>03708                                 nkn--;
<a name="l03709"></a>03709                         }
<a name="l03710"></a>03710                 }
<a name="l03711"></a>03711                 result += data[k] * blend;
<a name="l03712"></a>03712         }
<a name="l03713"></a>03713 
<a name="l03714"></a>03714         <span class="keywordflow">return</span> (result);
<a name="l03715"></a>03715 }
<a name="l03716"></a>03716 
<a name="l03729"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a74d59d17ba21ce5d8c84697989456bfb">03729</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a23bbdcb064bb80db48d4863871b60f3c" title="Draw a bezier curve with alpha blending.">bezierColor</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, <span class="keywordtype">int</span> s, Uint32 color)
<a name="l03730"></a>03730 {
<a name="l03731"></a>03731         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l03732"></a>03732         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aee708db5f0144ebf4a2fd13db69c6bb1" title="Draw a bezier curve with alpha blending.">bezierRGBA</a>(renderer, vx, vy, n, s, c[0], c[1], c[2], c[3]);
<a name="l03733"></a>03733 }
<a name="l03734"></a>03734 
<a name="l03750"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a6cb082e6eb4253d591927c6bf7eba06f">03750</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#aee708db5f0144ebf4a2fd13db69c6bb1" title="Draw a bezier curve with alpha blending.">bezierRGBA</a>(SDL_Renderer * renderer, <span class="keyword">const</span> Sint16 * vx, <span class="keyword">const</span> Sint16 * vy, <span class="keywordtype">int</span> n, <span class="keywordtype">int</span> s, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l03751"></a>03751 {
<a name="l03752"></a>03752         <span class="keywordtype">int</span> result;
<a name="l03753"></a>03753         <span class="keywordtype">int</span> i;
<a name="l03754"></a>03754         <span class="keywordtype">double</span> *x, *y, t, stepsize;
<a name="l03755"></a>03755         Sint16 x1, y1, x2, y2;
<a name="l03756"></a>03756 
<a name="l03757"></a>03757         <span class="comment">/*</span>
<a name="l03758"></a>03758 <span class="comment">        * Sanity check </span>
<a name="l03759"></a>03759 <span class="comment">        */</span>
<a name="l03760"></a>03760         <span class="keywordflow">if</span> (n &lt; 3) {
<a name="l03761"></a>03761                 <span class="keywordflow">return</span> (-1);
<a name="l03762"></a>03762         }
<a name="l03763"></a>03763         <span class="keywordflow">if</span> (s &lt; 2) {
<a name="l03764"></a>03764                 <span class="keywordflow">return</span> (-1);
<a name="l03765"></a>03765         }
<a name="l03766"></a>03766 
<a name="l03767"></a>03767         <span class="comment">/*</span>
<a name="l03768"></a>03768 <span class="comment">        * Variable setup </span>
<a name="l03769"></a>03769 <span class="comment">        */</span>
<a name="l03770"></a>03770         stepsize=(double)1.0/(<span class="keywordtype">double</span>)s;
<a name="l03771"></a>03771 
<a name="l03772"></a>03772         <span class="comment">/* Transfer vertices into float arrays */</span>
<a name="l03773"></a>03773         <span class="keywordflow">if</span> ((x=(<span class="keywordtype">double</span> *)malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>)*(n+1)))==NULL) {
<a name="l03774"></a>03774                 <span class="keywordflow">return</span>(-1);
<a name="l03775"></a>03775         }
<a name="l03776"></a>03776         <span class="keywordflow">if</span> ((y=(<span class="keywordtype">double</span> *)malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">double</span>)*(n+1)))==NULL) {
<a name="l03777"></a>03777                 free(x);
<a name="l03778"></a>03778                 <span class="keywordflow">return</span>(-1);
<a name="l03779"></a>03779         }    
<a name="l03780"></a>03780         <span class="keywordflow">for</span> (i=0; i&lt;n; i++) {
<a name="l03781"></a>03781                 x[i]=(double)vx[i];
<a name="l03782"></a>03782                 y[i]=(double)vy[i];
<a name="l03783"></a>03783         }      
<a name="l03784"></a>03784         x[n]=(double)vx[0];
<a name="l03785"></a>03785         y[n]=(double)vy[0];
<a name="l03786"></a>03786 
<a name="l03787"></a>03787         <span class="comment">/*</span>
<a name="l03788"></a>03788 <span class="comment">        * Set color </span>
<a name="l03789"></a>03789 <span class="comment">        */</span>
<a name="l03790"></a>03790         result = 0;
<a name="l03791"></a>03791         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l03792"></a>03792         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l03793"></a>03793 
<a name="l03794"></a>03794         <span class="comment">/*</span>
<a name="l03795"></a>03795 <span class="comment">        * Draw </span>
<a name="l03796"></a>03796 <span class="comment">        */</span>
<a name="l03797"></a>03797         t=0.0;
<a name="l03798"></a>03798         x1=(Sint16)lrint(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a888411ec724ddb9ff19cf9ba9fc067df" title="Internal function to calculate bezier interpolator of data array with ndata values at position &#39;t&#39;...">_evaluateBezier</a>(x,n+1,t));
<a name="l03799"></a>03799         y1=(Sint16)lrint(<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a888411ec724ddb9ff19cf9ba9fc067df" title="Internal function to calculate bezier interpolator of data array with ndata values at position &#39;t&#39;...">_evaluateBezier</a>(y,n+1,t));
<a name="l03800"></a>03800         <span class="keywordflow">for</span> (i = 0; i &lt;= (n*s); i++) {
<a name="l03801"></a>03801                 t += stepsize;
<a name="l03802"></a>03802                 x2=(Sint16)<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a888411ec724ddb9ff19cf9ba9fc067df" title="Internal function to calculate bezier interpolator of data array with ndata values at position &#39;t&#39;...">_evaluateBezier</a>(x,n,t);
<a name="l03803"></a>03803                 y2=(Sint16)<a class="code" href="_s_d_l2__gfx_primitives_8c.html#a888411ec724ddb9ff19cf9ba9fc067df" title="Internal function to calculate bezier interpolator of data array with ndata values at position &#39;t&#39;...">_evaluateBezier</a>(y,n,t);
<a name="l03804"></a>03804                 result |= <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ac8efb30db084f16211f1f1dd648df618" title="Draw line with alpha blending using the currently set color.">line</a>(renderer, x1, y1, x2, y2);
<a name="l03805"></a>03805                 x1 = x2;
<a name="l03806"></a>03806                 y1 = y2;
<a name="l03807"></a>03807         }
<a name="l03808"></a>03808 
<a name="l03809"></a>03809         <span class="comment">/* Clean up temporary array */</span>
<a name="l03810"></a>03810         free(x);
<a name="l03811"></a>03811         free(y);
<a name="l03812"></a>03812 
<a name="l03813"></a>03813         <span class="keywordflow">return</span> (result);
<a name="l03814"></a>03814 }
<a name="l03815"></a>03815 
<a name="l03816"></a>03816 
<a name="l03817"></a>03817 <span class="comment">/* ---- Thick Line */</span>
<a name="l03818"></a>03818 
<a name="l03837"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#af2731f17a2e4d7d765e47392bdba7d7e">03837</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#af2731f17a2e4d7d765e47392bdba7d7e" title="Internal function to initialize the Bresenham line iterator.">_bresenhamInitialize</a>(<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html" title="The structure passed to the internal Bresenham iterator.">SDL2_gfxBresenhamIterator</a> *b, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2)
<a name="l03838"></a>03838 {
<a name="l03839"></a>03839         <span class="keywordtype">int</span> temp;
<a name="l03840"></a>03840 
<a name="l03841"></a>03841         <span class="keywordflow">if</span> (b==NULL) {
<a name="l03842"></a>03842                 <span class="keywordflow">return</span>(-1);
<a name="l03843"></a>03843         }
<a name="l03844"></a>03844 
<a name="l03845"></a>03845         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ae80d529920f12a3d3eda29b1a29e2e8a">x</a> = x1;
<a name="l03846"></a>03846         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a> = y1;
<a name="l03847"></a>03847 
<a name="l03848"></a>03848         <span class="comment">/* dx = abs(x2-x1), s1 = sign(x2-x1) */</span>
<a name="l03849"></a>03849         <span class="keywordflow">if</span> ((b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a> = x2 - x1) != 0) {
<a name="l03850"></a>03850                 <span class="keywordflow">if</span> (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a> &lt; 0) {
<a name="l03851"></a>03851                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a> = -b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a>;
<a name="l03852"></a>03852                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#acfb6b9e2b00e34da4313b463c341e597">s1</a> = -1;
<a name="l03853"></a>03853                 } <span class="keywordflow">else</span> {
<a name="l03854"></a>03854                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#acfb6b9e2b00e34da4313b463c341e597">s1</a> = 1;
<a name="l03855"></a>03855                 }
<a name="l03856"></a>03856         } <span class="keywordflow">else</span> {
<a name="l03857"></a>03857                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#acfb6b9e2b00e34da4313b463c341e597">s1</a> = 0;      
<a name="l03858"></a>03858         }
<a name="l03859"></a>03859 
<a name="l03860"></a>03860         <span class="comment">/* dy = abs(y2-y1), s2 = sign(y2-y1)    */</span>
<a name="l03861"></a>03861         <span class="keywordflow">if</span> ((b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a> = y2 - y1) != 0) {
<a name="l03862"></a>03862                 <span class="keywordflow">if</span> (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a> &lt; 0) {
<a name="l03863"></a>03863                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a> = -b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a>;
<a name="l03864"></a>03864                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4c68ffea7c3affb6a0ee6219aba89a69">s2</a> = -1;
<a name="l03865"></a>03865                 } <span class="keywordflow">else</span> {
<a name="l03866"></a>03866                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4c68ffea7c3affb6a0ee6219aba89a69">s2</a> = 1;
<a name="l03867"></a>03867                 }
<a name="l03868"></a>03868         } <span class="keywordflow">else</span> {
<a name="l03869"></a>03869                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4c68ffea7c3affb6a0ee6219aba89a69">s2</a> = 0;      
<a name="l03870"></a>03870         }
<a name="l03871"></a>03871 
<a name="l03872"></a>03872         <span class="keywordflow">if</span> (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a> &gt; b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a>) {
<a name="l03873"></a>03873                 temp = b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a>;
<a name="l03874"></a>03874                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a> = b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a>;
<a name="l03875"></a>03875                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a> = temp;
<a name="l03876"></a>03876                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ace147c79e29f2efd14e5744efcb976af">swapdir</a> = 1;
<a name="l03877"></a>03877         } <span class="keywordflow">else</span> {
<a name="l03878"></a>03878                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ace147c79e29f2efd14e5744efcb976af">swapdir</a> = 0;
<a name="l03879"></a>03879         }
<a name="l03880"></a>03880 
<a name="l03881"></a>03881         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a92fcd448f278df155fd5472527a6dc47">count</a> = (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a>&lt;0) ? 0 : (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a>;
<a name="l03882"></a>03882         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a> &lt;&lt;= 1;
<a name="l03883"></a>03883         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a11614f44ef4d939bdd984953346a7572">error</a> = b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a> - b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a>;
<a name="l03884"></a>03884         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a> &lt;&lt;= 1;    
<a name="l03885"></a>03885 
<a name="l03886"></a>03886         <span class="keywordflow">return</span>(0);
<a name="l03887"></a>03887 }
<a name="l03888"></a>03888 
<a name="l03889"></a>03889 
<a name="l03899"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#ad052c2880dd90acc6846dc050e0acaab">03899</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#ad052c2880dd90acc6846dc050e0acaab" title="Internal function to move Bresenham line iterator to the next position.">_bresenhamIterate</a>(<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html" title="The structure passed to the internal Bresenham iterator.">SDL2_gfxBresenhamIterator</a> *b)
<a name="l03900"></a>03900 {       
<a name="l03901"></a>03901         <span class="keywordflow">if</span> (b==NULL) {
<a name="l03902"></a>03902                 <span class="keywordflow">return</span> (-1);
<a name="l03903"></a>03903         }
<a name="l03904"></a>03904 
<a name="l03905"></a>03905         <span class="comment">/* last point check */</span>
<a name="l03906"></a>03906         <span class="keywordflow">if</span> (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a92fcd448f278df155fd5472527a6dc47">count</a>==0) {
<a name="l03907"></a>03907                 <span class="keywordflow">return</span> (2);
<a name="l03908"></a>03908         }
<a name="l03909"></a>03909 
<a name="l03910"></a>03910         <span class="keywordflow">while</span> (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a11614f44ef4d939bdd984953346a7572">error</a> &gt;= 0) {
<a name="l03911"></a>03911                 <span class="keywordflow">if</span> (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ace147c79e29f2efd14e5744efcb976af">swapdir</a>) {
<a name="l03912"></a>03912                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ae80d529920f12a3d3eda29b1a29e2e8a">x</a> += b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#acfb6b9e2b00e34da4313b463c341e597">s1</a>;
<a name="l03913"></a>03913                 } <span class="keywordflow">else</span>  {
<a name="l03914"></a>03914                         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a> += b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4c68ffea7c3affb6a0ee6219aba89a69">s2</a>;
<a name="l03915"></a>03915                 }
<a name="l03916"></a>03916 
<a name="l03917"></a>03917                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a11614f44ef4d939bdd984953346a7572">error</a> -= b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a6a0d40b2ed6d9e674f93396212f0028f">dx</a>;
<a name="l03918"></a>03918         }
<a name="l03919"></a>03919 
<a name="l03920"></a>03920         <span class="keywordflow">if</span> (b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ace147c79e29f2efd14e5744efcb976af">swapdir</a>) {
<a name="l03921"></a>03921                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a> += b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4c68ffea7c3affb6a0ee6219aba89a69">s2</a>;
<a name="l03922"></a>03922         } <span class="keywordflow">else</span> {
<a name="l03923"></a>03923                 b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ae80d529920f12a3d3eda29b1a29e2e8a">x</a> += b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#acfb6b9e2b00e34da4313b463c341e597">s1</a>;
<a name="l03924"></a>03924         }
<a name="l03925"></a>03925 
<a name="l03926"></a>03926         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a11614f44ef4d939bdd984953346a7572">error</a> += b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a4817151aee120cc100c400d3076f4b93">dy</a>;      
<a name="l03927"></a>03927         b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a92fcd448f278df155fd5472527a6dc47">count</a>--;             
<a name="l03928"></a>03928 
<a name="l03929"></a>03929         <span class="comment">/* count==0 indicates &quot;end-of-line&quot; */</span>
<a name="l03930"></a>03930         <span class="keywordflow">return</span> ((b-&gt;<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a92fcd448f278df155fd5472527a6dc47">count</a>) ? 0 : 1);
<a name="l03931"></a>03931 }
<a name="l03932"></a>03932 
<a name="l03933"></a>03933 
<a name="l03942"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a4aaefb01b776e3b567b8325c701fd507">03942</a> <span class="keywordtype">void</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a4aaefb01b776e3b567b8325c701fd507" title="Internal function to to draw parallel lines with Murphy algorithm.">_murphyParaline</a>(<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html" title="The structure passed to the internal Murphy iterator.">SDL2_gfxMurphyIterator</a> *m, Sint16 x, Sint16 y, <span class="keywordtype">int</span> d1)
<a name="l03943"></a>03943 {
<a name="l03944"></a>03944         <span class="keywordtype">int</span> p;
<a name="l03945"></a>03945         d1 = -d1;
<a name="l03946"></a>03946 
<a name="l03947"></a>03947         <span class="keywordflow">for</span> (p = 0; p &lt;= m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a>; p++) {
<a name="l03948"></a>03948 
<a name="l03949"></a>03949                 <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a>, x, y);
<a name="l03950"></a>03950 
<a name="l03951"></a>03951                 <span class="keywordflow">if</span> (d1 &lt;= m-&gt;kt) {
<a name="l03952"></a>03952                         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> == 0) {
<a name="l03953"></a>03953                                 x++;
<a name="l03954"></a>03954                         } <span class="keywordflow">else</span> {
<a name="l03955"></a>03955                                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l03956"></a>03956                                         y++;
<a name="l03957"></a>03957                                 } <span class="keywordflow">else</span> {
<a name="l03958"></a>03958                                         y--;
<a name="l03959"></a>03959                                 }
<a name="l03960"></a>03960                         }
<a name="l03961"></a>03961                         d1 += m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a>;
<a name="l03962"></a>03962                 } <span class="keywordflow">else</span> {        
<a name="l03963"></a>03963                         x++;
<a name="l03964"></a>03964                         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l03965"></a>03965                                 y++;
<a name="l03966"></a>03966                         } <span class="keywordflow">else</span> {
<a name="l03967"></a>03967                                 y--;
<a name="l03968"></a>03968                         }
<a name="l03969"></a>03969                         d1 += m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ade809c6ad2d8ae1dc2f665077951b81a">kd</a>;
<a name="l03970"></a>03970                 }
<a name="l03971"></a>03971         }
<a name="l03972"></a>03972 
<a name="l03973"></a>03973         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af4320e1b2f9da1ee4155b6cfe35c8d7e">tempx</a> = x;
<a name="l03974"></a>03974         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a4c3e88fc7abb5715d04e28d96a154e5f">tempy</a> = y;
<a name="l03975"></a>03975 }
<a name="l03976"></a>03976 
<a name="l03992"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a46be62225b445b75ee0a581f6c26fe44">03992</a> <span class="keywordtype">void</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a46be62225b445b75ee0a581f6c26fe44" title="Internal function to to draw one iteration of the Murphy algorithm.">_murphyIteration</a>(<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html" title="The structure passed to the internal Murphy iterator.">SDL2_gfxMurphyIterator</a> *m, Uint8 miter, 
<a name="l03993"></a>03993         Uint16 ml1bx, Uint16 ml1by, Uint16 ml2bx, Uint16 ml2by, 
<a name="l03994"></a>03994         Uint16 ml1x, Uint16 ml1y, Uint16 ml2x, Uint16 ml2y)
<a name="l03995"></a>03995 {
<a name="l03996"></a>03996         <span class="keywordtype">int</span> atemp1, atemp2;
<a name="l03997"></a>03997         <span class="keywordtype">int</span> ftmp1, ftmp2;
<a name="l03998"></a>03998         Uint16 m1x, m1y, m2x, m2y;      
<a name="l03999"></a>03999         Uint16 fix, fiy, lax, lay, curx, cury;
<a name="l04000"></a>04000         Sint16 px[4], py[4];
<a name="l04001"></a>04001         <a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html" title="The structure passed to the internal Bresenham iterator.">SDL2_gfxBresenhamIterator</a> b;
<a name="l04002"></a>04002 
<a name="l04003"></a>04003         <span class="keywordflow">if</span> (miter &gt; 1) {
<a name="l04004"></a>04004                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a20a0f29217c4df1896f0b5b2e0db8901">first1x</a> != -32768) {
<a name="l04005"></a>04005                         fix = (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a20a0f29217c4df1896f0b5b2e0db8901">first1x</a> + m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a0043c9be4575c0c75cda25d9cec09deb">first2x</a>) / 2;
<a name="l04006"></a>04006                         fiy = (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1e6adb477c4b1db15853adf1b5340760">first1y</a> + m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8c0bb60c5be224d8d7fd4d4fd74930c">first2y</a>) / 2;
<a name="l04007"></a>04007                         lax = (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#adc37a4a286331a97587fdf4f239fa5e6">last1x</a> + m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1acb203975c193230a03cee26bbd3f97">last2x</a>) / 2;
<a name="l04008"></a>04008                         lay = (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a48dabb55f39ba73ecacc558eba6f5b15">last1y</a> + m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab85d5d3386d741c19de5bc0a7767d185">last2y</a>) / 2;
<a name="l04009"></a>04009                         curx = (ml1x + ml2x) / 2;
<a name="l04010"></a>04010                         cury = (ml1y + ml2y) / 2;
<a name="l04011"></a>04011 
<a name="l04012"></a>04012                         atemp1 = (fix - curx);
<a name="l04013"></a>04013                         atemp2 = (fiy - cury);
<a name="l04014"></a>04014                         ftmp1 = atemp1 * atemp1 + atemp2 * atemp2;
<a name="l04015"></a>04015                         atemp1 = (lax - curx);
<a name="l04016"></a>04016                         atemp2 = (lay - cury);
<a name="l04017"></a>04017                         ftmp2 = atemp1 * atemp1 + atemp2 * atemp2;
<a name="l04018"></a>04018 
<a name="l04019"></a>04019                         <span class="keywordflow">if</span> (ftmp1 &lt;= ftmp2) {
<a name="l04020"></a>04020                                 m1x = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a20a0f29217c4df1896f0b5b2e0db8901">first1x</a>;
<a name="l04021"></a>04021                                 m1y = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1e6adb477c4b1db15853adf1b5340760">first1y</a>;
<a name="l04022"></a>04022                                 m2x = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a0043c9be4575c0c75cda25d9cec09deb">first2x</a>;
<a name="l04023"></a>04023                                 m2y = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8c0bb60c5be224d8d7fd4d4fd74930c">first2y</a>;
<a name="l04024"></a>04024                         } <span class="keywordflow">else</span> {
<a name="l04025"></a>04025                                 m1x = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#adc37a4a286331a97587fdf4f239fa5e6">last1x</a>;
<a name="l04026"></a>04026                                 m1y = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a48dabb55f39ba73ecacc558eba6f5b15">last1y</a>;
<a name="l04027"></a>04027                                 m2x = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1acb203975c193230a03cee26bbd3f97">last2x</a>;
<a name="l04028"></a>04028                                 m2y = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab85d5d3386d741c19de5bc0a7767d185">last2y</a>;
<a name="l04029"></a>04029                         }
<a name="l04030"></a>04030 
<a name="l04031"></a>04031                         atemp1 = (m2x - ml2x);
<a name="l04032"></a>04032                         atemp2 = (m2y - ml2y);
<a name="l04033"></a>04033                         ftmp1 = atemp1 * atemp1 + atemp2 * atemp2;
<a name="l04034"></a>04034                         atemp1 = (m2x - ml2bx);
<a name="l04035"></a>04035                         atemp2 = (m2y - ml2by);
<a name="l04036"></a>04036                         ftmp2 = atemp1 * atemp1 + atemp2 * atemp2;
<a name="l04037"></a>04037 
<a name="l04038"></a>04038                         <span class="keywordflow">if</span> (ftmp2 &gt;= ftmp1) {
<a name="l04039"></a>04039                                 ftmp1 = ml2bx;
<a name="l04040"></a>04040                                 ftmp2 = ml2by;
<a name="l04041"></a>04041                                 ml2bx = ml2x;
<a name="l04042"></a>04042                                 ml2by = ml2y;
<a name="l04043"></a>04043                                 ml2x = ftmp1;
<a name="l04044"></a>04044                                 ml2y = ftmp2;
<a name="l04045"></a>04045                                 ftmp1 = ml1bx;
<a name="l04046"></a>04046                                 ftmp2 = ml1by;
<a name="l04047"></a>04047                                 ml1bx = ml1x;
<a name="l04048"></a>04048                                 ml1by = ml1y;
<a name="l04049"></a>04049                                 ml1x = ftmp1;
<a name="l04050"></a>04050                                 ml1y = ftmp2;
<a name="l04051"></a>04051                         }
<a name="l04052"></a>04052 
<a name="l04053"></a>04053                         <span class="comment">/*</span>
<a name="l04054"></a>04054 <span class="comment">                        * Lock the surface </span>
<a name="l04055"></a>04055 <span class="comment">                        */</span>
<a name="l04056"></a>04056                         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#af2731f17a2e4d7d765e47392bdba7d7e" title="Internal function to initialize the Bresenham line iterator.">_bresenhamInitialize</a>(&amp;b, m2x, m2y, m1x, m1y);
<a name="l04057"></a>04057                         <span class="keywordflow">do</span> {
<a name="l04058"></a>04058                                 <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ae80d529920f12a3d3eda29b1a29e2e8a">x</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a>);
<a name="l04059"></a>04059                         } <span class="keywordflow">while</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ad052c2880dd90acc6846dc050e0acaab" title="Internal function to move Bresenham line iterator to the next position.">_bresenhamIterate</a>(&amp;b)==0);
<a name="l04060"></a>04060 
<a name="l04061"></a>04061                         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#af2731f17a2e4d7d765e47392bdba7d7e" title="Internal function to initialize the Bresenham line iterator.">_bresenhamInitialize</a>(&amp;b, m1x, m1y, ml1bx, ml1by);
<a name="l04062"></a>04062                         <span class="keywordflow">do</span> {
<a name="l04063"></a>04063                                 <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ae80d529920f12a3d3eda29b1a29e2e8a">x</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a>);
<a name="l04064"></a>04064                         } <span class="keywordflow">while</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ad052c2880dd90acc6846dc050e0acaab" title="Internal function to move Bresenham line iterator to the next position.">_bresenhamIterate</a>(&amp;b)==0);
<a name="l04065"></a>04065 
<a name="l04066"></a>04066                         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#af2731f17a2e4d7d765e47392bdba7d7e" title="Internal function to initialize the Bresenham line iterator.">_bresenhamInitialize</a>(&amp;b, ml1bx, ml1by, ml2bx, ml2by);
<a name="l04067"></a>04067                         <span class="keywordflow">do</span> {
<a name="l04068"></a>04068                                 <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ae80d529920f12a3d3eda29b1a29e2e8a">x</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a>);
<a name="l04069"></a>04069                         } <span class="keywordflow">while</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ad052c2880dd90acc6846dc050e0acaab" title="Internal function to move Bresenham line iterator to the next position.">_bresenhamIterate</a>(&amp;b)==0);
<a name="l04070"></a>04070 
<a name="l04071"></a>04071                         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#af2731f17a2e4d7d765e47392bdba7d7e" title="Internal function to initialize the Bresenham line iterator.">_bresenhamInitialize</a>(&amp;b, ml2bx, ml2by, m2x, m2y);
<a name="l04072"></a>04072                         <span class="keywordflow">do</span> {
<a name="l04073"></a>04073                                 <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a3ec9c334d5e0786dd27924d210b41bb8" title="Draw pixel in currently set color.">pixel</a>(m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#ae80d529920f12a3d3eda29b1a29e2e8a">x</a>, b.<a class="code" href="struct_s_d_l2__gfx_bresenham_iterator.html#a48ddc054175e25d435c217ad4639c3a1">y</a>);
<a name="l04074"></a>04074                         } <span class="keywordflow">while</span> (<a class="code" href="_s_d_l2__gfx_primitives_8c.html#ad052c2880dd90acc6846dc050e0acaab" title="Internal function to move Bresenham line iterator to the next position.">_bresenhamIterate</a>(&amp;b)==0);
<a name="l04075"></a>04075 
<a name="l04076"></a>04076                         px[0] = m1x;
<a name="l04077"></a>04077                         px[1] = m2x;
<a name="l04078"></a>04078                         px[2] = ml1bx;
<a name="l04079"></a>04079                         px[3] = ml2bx;
<a name="l04080"></a>04080                         py[0] = m1y;
<a name="l04081"></a>04081                         py[1] = m2y;
<a name="l04082"></a>04082                         py[2] = ml1by;
<a name="l04083"></a>04083                         py[3] = ml2by;                  
<a name="l04084"></a>04084                         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a635ed8b4c7321f75d00938130edf2007" title="Draw polygon with the currently set color and blend mode.">polygon</a>(m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a>, px, py, 4);                                                
<a name="l04085"></a>04085                 }
<a name="l04086"></a>04086         }
<a name="l04087"></a>04087 
<a name="l04088"></a>04088         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#adc37a4a286331a97587fdf4f239fa5e6">last1x</a> = ml1x;
<a name="l04089"></a>04089         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a48dabb55f39ba73ecacc558eba6f5b15">last1y</a> = ml1y;
<a name="l04090"></a>04090         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1acb203975c193230a03cee26bbd3f97">last2x</a> = ml2x;
<a name="l04091"></a>04091         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab85d5d3386d741c19de5bc0a7767d185">last2y</a> = ml2y;
<a name="l04092"></a>04092         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a20a0f29217c4df1896f0b5b2e0db8901">first1x</a> = ml1bx;
<a name="l04093"></a>04093         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1e6adb477c4b1db15853adf1b5340760">first1y</a> = ml1by;
<a name="l04094"></a>04094         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a0043c9be4575c0c75cda25d9cec09deb">first2x</a> = ml2bx;
<a name="l04095"></a>04095         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8c0bb60c5be224d8d7fd4d4fd74930c">first2y</a> = ml2by;
<a name="l04096"></a>04096 }
<a name="l04097"></a>04097 
<a name="l04098"></a>04098 
<a name="l04099"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#a764ddb925da0921f024fadb4c12d7382">04099</a> <span class="preprocessor">#define HYPOT(x,y) sqrt((double)(x)*(double)(x)+(double)(y)*(double)(y)) </span>
<a name="l04100"></a>04100 <span class="preprocessor"></span>
<a name="l04115"></a><a class="code" href="_s_d_l2__gfx_primitives_8c.html#abc1df7ada979012cef99920e741cf559">04115</a> <span class="keywordtype">void</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#abc1df7ada979012cef99920e741cf559" title="Internal function to to draw wide lines with Murphy algorithm.">_murphyWideline</a>(<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html" title="The structure passed to the internal Murphy iterator.">SDL2_gfxMurphyIterator</a> *m, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 miter)
<a name="l04116"></a>04116 {       
<a name="l04117"></a>04117         <span class="keywordtype">float</span> offset = (float)width / 2.f;
<a name="l04118"></a>04118 
<a name="l04119"></a>04119         Sint16 temp;
<a name="l04120"></a>04120         Sint16 ptx, pty, ptxx, ptxy, ml1x, ml1y, ml2x, ml2y, ml1bx, ml1by, ml2bx, ml2by;
<a name="l04121"></a>04121 
<a name="l04122"></a>04122         <span class="keywordtype">int</span> d0, d1;             <span class="comment">/* difference terms d0=perpendicular to line, d1=along line */</span>
<a name="l04123"></a>04123 
<a name="l04124"></a>04124         <span class="keywordtype">int</span> q;                  <span class="comment">/* pel counter,q=perpendicular to line */</span>
<a name="l04125"></a>04125         <span class="keywordtype">int</span> tmp;
<a name="l04126"></a>04126 
<a name="l04127"></a>04127         <span class="keywordtype">int</span> dd;                 <span class="comment">/* distance along line */</span>
<a name="l04128"></a>04128         <span class="keywordtype">int</span> tk;                 <span class="comment">/* thickness threshold */</span>
<a name="l04129"></a>04129         <span class="keywordtype">double</span> ang;             <span class="comment">/* angle for initial point calculation */</span>
<a name="l04130"></a>04130         <span class="keywordtype">double</span> sang, cang;
<a name="l04131"></a>04131 
<a name="l04132"></a>04132         <span class="comment">/* Initialisation */</span>
<a name="l04133"></a>04133         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a> = x2 - x1; <span class="comment">/* delta x */</span>
<a name="l04134"></a>04134         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> = y2 - y1; <span class="comment">/* delta y */</span>
<a name="l04135"></a>04135 
<a name="l04136"></a>04136         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a> &lt; 0) { <span class="comment">/* swap to make sure we are in quadrants 1 or 4 */</span>
<a name="l04137"></a>04137                 temp = x1;
<a name="l04138"></a>04138                 x1 = x2;
<a name="l04139"></a>04139                 x2 = temp;
<a name="l04140"></a>04140                 temp = y1;
<a name="l04141"></a>04141                 y1 = y2;
<a name="l04142"></a>04142                 y2 = temp;              
<a name="l04143"></a>04143                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a> *= -1;
<a name="l04144"></a>04144                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> *= -1;
<a name="l04145"></a>04145         }
<a name="l04146"></a>04146 
<a name="l04147"></a>04147         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> &lt; 0) { <span class="comment">/* swap to 1st quadrant and flag */</span>
<a name="l04148"></a>04148                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> *= -1;
<a name="l04149"></a>04149                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> = 1;
<a name="l04150"></a>04150         } <span class="keywordflow">else</span> {
<a name="l04151"></a>04151                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> = 0;
<a name="l04152"></a>04152         }
<a name="l04153"></a>04153 
<a name="l04154"></a>04154         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> &gt; m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a>) {      <span class="comment">/* swap things if in 2 octant */</span>
<a name="l04155"></a>04155                 tmp = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a>;
<a name="l04156"></a>04156                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a> = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a>;
<a name="l04157"></a>04157                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> = tmp;
<a name="l04158"></a>04158                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> = 1;
<a name="l04159"></a>04159         } <span class="keywordflow">else</span> {
<a name="l04160"></a>04160                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> = 0;
<a name="l04161"></a>04161         }
<a name="l04162"></a>04162 
<a name="l04163"></a>04163         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a2d8fc6210660a003e60ac96216cdd9d1">ku</a> = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a> + m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a>;    <span class="comment">/* change in l for square shift */</span>
<a name="l04164"></a>04164         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a> = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> + m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a>;    <span class="comment">/* change in d for square shift */</span>
<a name="l04165"></a>04165         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ade809c6ad2d8ae1dc2f665077951b81a">kd</a> = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a> - m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a2d8fc6210660a003e60ac96216cdd9d1">ku</a>;  <span class="comment">/* change in d for diagonal shift */</span>
<a name="l04166"></a>04166         m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac77eef4f813ec344cf850b89cc68818d">kt</a> = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a> - m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a>;   <span class="comment">/* diag/square decision threshold */</span>
<a name="l04167"></a>04167 
<a name="l04168"></a>04168         d0 = 0;
<a name="l04169"></a>04169         d1 = 0;
<a name="l04170"></a>04170         dd = 0;
<a name="l04171"></a>04171 
<a name="l04172"></a>04172         ang = atan((<span class="keywordtype">double</span>) m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a> / (<span class="keywordtype">double</span>) m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a>);      <span class="comment">/* calc new initial point - offset both sides of ideal */</span>       
<a name="l04173"></a>04173         sang = sin(ang);
<a name="l04174"></a>04174         cang = cos(ang);
<a name="l04175"></a>04175 
<a name="l04176"></a>04176         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> == 0) {
<a name="l04177"></a>04177                 ptx = x1 + (Sint16)lrint(offset * sang);
<a name="l04178"></a>04178                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l04179"></a>04179                         pty = y1 - (Sint16)lrint(offset * cang);
<a name="l04180"></a>04180                 } <span class="keywordflow">else</span> {
<a name="l04181"></a>04181                         pty = y1 + (Sint16)lrint(offset * cang);
<a name="l04182"></a>04182                 }
<a name="l04183"></a>04183         } <span class="keywordflow">else</span> {
<a name="l04184"></a>04184                 ptx = x1 - (Sint16)lrint(offset * cang);
<a name="l04185"></a>04185                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l04186"></a>04186                         pty = y1 + (Sint16)lrint(offset * sang);
<a name="l04187"></a>04187                 } <span class="keywordflow">else</span> {
<a name="l04188"></a>04188                         pty = y1 - (Sint16)lrint(offset * sang);
<a name="l04189"></a>04189                 }
<a name="l04190"></a>04190         }
<a name="l04191"></a>04191 
<a name="l04192"></a>04192         <span class="comment">/* used here for constant thickness line */</span>
<a name="l04193"></a>04193         tk = (int) (4. * <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a764ddb925da0921f024fadb4c12d7382">HYPOT</a>(ptx - x1, pty - y1) * <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a764ddb925da0921f024fadb4c12d7382">HYPOT</a>(m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a5874b4c2ec2e28321eea4e4871d08222">u</a>, m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8859e8c1ce357c4c8b37bbb1936ba1c">v</a>));
<a name="l04194"></a>04194 
<a name="l04195"></a>04195         <span class="keywordflow">if</span> (miter == 0) {
<a name="l04196"></a>04196                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a20a0f29217c4df1896f0b5b2e0db8901">first1x</a> = -32768;
<a name="l04197"></a>04197                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1e6adb477c4b1db15853adf1b5340760">first1y</a> = -32768;
<a name="l04198"></a>04198                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a0043c9be4575c0c75cda25d9cec09deb">first2x</a> = -32768;
<a name="l04199"></a>04199                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac8c0bb60c5be224d8d7fd4d4fd74930c">first2y</a> = -32768;
<a name="l04200"></a>04200                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#adc37a4a286331a97587fdf4f239fa5e6">last1x</a> = -32768;
<a name="l04201"></a>04201                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a48dabb55f39ba73ecacc558eba6f5b15">last1y</a> = -32768;
<a name="l04202"></a>04202                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a1acb203975c193230a03cee26bbd3f97">last2x</a> = -32768;
<a name="l04203"></a>04203                 m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab85d5d3386d741c19de5bc0a7767d185">last2y</a> = -32768;
<a name="l04204"></a>04204         }
<a name="l04205"></a>04205         ptxx = ptx;
<a name="l04206"></a>04206         ptxy = pty;
<a name="l04207"></a>04207 
<a name="l04208"></a>04208         <span class="keywordflow">for</span> (q = 0; dd &lt;= tk; q++) {    <span class="comment">/* outer loop, stepping perpendicular to line */</span>
<a name="l04209"></a>04209 
<a name="l04210"></a>04210                 <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a4aaefb01b776e3b567b8325c701fd507" title="Internal function to to draw parallel lines with Murphy algorithm.">_murphyParaline</a>(m, ptx, pty, d1);       <span class="comment">/* call to inner loop - right edge */</span>
<a name="l04211"></a>04211                 <span class="keywordflow">if</span> (q == 0) {
<a name="l04212"></a>04212                         ml1x = ptx;
<a name="l04213"></a>04213                         ml1y = pty;
<a name="l04214"></a>04214                         ml1bx = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af4320e1b2f9da1ee4155b6cfe35c8d7e">tempx</a>;
<a name="l04215"></a>04215                         ml1by = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a4c3e88fc7abb5715d04e28d96a154e5f">tempy</a>;
<a name="l04216"></a>04216                 } <span class="keywordflow">else</span> {
<a name="l04217"></a>04217                         ml2x = ptx;
<a name="l04218"></a>04218                         ml2y = pty;
<a name="l04219"></a>04219                         ml2bx = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af4320e1b2f9da1ee4155b6cfe35c8d7e">tempx</a>;
<a name="l04220"></a>04220                         ml2by = m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a4c3e88fc7abb5715d04e28d96a154e5f">tempy</a>;
<a name="l04221"></a>04221                 }
<a name="l04222"></a>04222                 <span class="keywordflow">if</span> (d0 &lt; m-&gt;kt) {       <span class="comment">/* square move */</span>
<a name="l04223"></a>04223                         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> == 0) {
<a name="l04224"></a>04224                                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l04225"></a>04225                                         pty++;
<a name="l04226"></a>04226                                 } <span class="keywordflow">else</span> {
<a name="l04227"></a>04227                                         pty--;
<a name="l04228"></a>04228                                 }
<a name="l04229"></a>04229                         } <span class="keywordflow">else</span> {
<a name="l04230"></a>04230                                 ptx++;
<a name="l04231"></a>04231                         }
<a name="l04232"></a>04232                 } <span class="keywordflow">else</span> {        <span class="comment">/* diagonal move */</span>
<a name="l04233"></a>04233                         dd += m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a>;
<a name="l04234"></a>04234                         d0 -= m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a2d8fc6210660a003e60ac96216cdd9d1">ku</a>;
<a name="l04235"></a>04235                         <span class="keywordflow">if</span> (d1 &lt; m-&gt;kt) {       <span class="comment">/* normal diagonal */</span>
<a name="l04236"></a>04236                                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> == 0) {
<a name="l04237"></a>04237                                         ptx--;
<a name="l04238"></a>04238                                         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l04239"></a>04239                                                 pty++;
<a name="l04240"></a>04240                                         } <span class="keywordflow">else</span> {
<a name="l04241"></a>04241                                                 pty--;
<a name="l04242"></a>04242                                         }
<a name="l04243"></a>04243                                 } <span class="keywordflow">else</span> {
<a name="l04244"></a>04244                                         ptx++;
<a name="l04245"></a>04245                                         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l04246"></a>04246                                                 pty--;
<a name="l04247"></a>04247                                         } <span class="keywordflow">else</span> {
<a name="l04248"></a>04248                                                 pty++;
<a name="l04249"></a>04249                                         }
<a name="l04250"></a>04250                                 }
<a name="l04251"></a>04251                                 d1 += m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a>;
<a name="l04252"></a>04252                         } <span class="keywordflow">else</span> {        <span class="comment">/* double square move, extra parallel line */</span>
<a name="l04253"></a>04253                                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> == 0) {
<a name="l04254"></a>04254                                         ptx--;
<a name="l04255"></a>04255                                 } <span class="keywordflow">else</span> {
<a name="l04256"></a>04256                                         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l04257"></a>04257                                                 pty--;
<a name="l04258"></a>04258                                         } <span class="keywordflow">else</span> {
<a name="l04259"></a>04259                                                 pty++;
<a name="l04260"></a>04260                                         }
<a name="l04261"></a>04261                                 }
<a name="l04262"></a>04262                                 d1 += m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ade809c6ad2d8ae1dc2f665077951b81a">kd</a>;
<a name="l04263"></a>04263                                 <span class="keywordflow">if</span> (dd &gt; tk) {
<a name="l04264"></a>04264                                         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a46be62225b445b75ee0a581f6c26fe44" title="Internal function to to draw one iteration of the Murphy algorithm.">_murphyIteration</a>(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y);
<a name="l04265"></a>04265                                         <span class="keywordflow">return</span>; <span class="comment">/* breakout on the extra line */</span>
<a name="l04266"></a>04266                                 }
<a name="l04267"></a>04267                                 <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a4aaefb01b776e3b567b8325c701fd507" title="Internal function to to draw parallel lines with Murphy algorithm.">_murphyParaline</a>(m, ptx, pty, d1);
<a name="l04268"></a>04268                                 <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ab9894ea9f5570af0e7fa86e61a3bb60b">oct2</a> == 0) {
<a name="l04269"></a>04269                                         <span class="keywordflow">if</span> (m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#ac65502ab7d0d8cbf739c6e06c35d8edb">quad4</a> == 0) {
<a name="l04270"></a>04270                                                 pty++;
<a name="l04271"></a>04271                                         } <span class="keywordflow">else</span> {
<a name="l04272"></a>04272 
<a name="l04273"></a>04273                                                 pty--;
<a name="l04274"></a>04274                                         }
<a name="l04275"></a>04275                                 } <span class="keywordflow">else</span> {
<a name="l04276"></a>04276                                         ptx++;
<a name="l04277"></a>04277                                 }
<a name="l04278"></a>04278                         }
<a name="l04279"></a>04279                 }
<a name="l04280"></a>04280                 dd += m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a2d8fc6210660a003e60ac96216cdd9d1">ku</a>;
<a name="l04281"></a>04281                 d0 += m-&gt;<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#af59597daf52972ab61551495c3d7e6cd">kv</a>;
<a name="l04282"></a>04282         }
<a name="l04283"></a>04283 
<a name="l04284"></a>04284         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a46be62225b445b75ee0a581f6c26fe44" title="Internal function to to draw one iteration of the Murphy algorithm.">_murphyIteration</a>(m, miter, ml1bx, ml1by, ml2bx, ml2by, ml1x, ml1y, ml2x, ml2y);
<a name="l04285"></a>04285 }
<a name="l04286"></a>04286 
<a name="l04287"></a>04287 
<a name="l04301"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a613c16293c3571b695cc0c60358bb862">04301</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a65c3119156482e660d4f4a3e084eb2ab" title="Draw a thick line with alpha blending.">thickLineColor</a>(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint32 color)
<a name="l04302"></a>04302 {       
<a name="l04303"></a>04303         Uint8 *c = (Uint8 *)&amp;color; 
<a name="l04304"></a>04304         <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a20297b17afd1e3686589bf74ebd17482" title="Draw a thick line with alpha blending.">thickLineRGBA</a>(renderer, x1, y1, x2, y2, width, c[0], c[1], c[2], c[3]);
<a name="l04305"></a>04305 }
<a name="l04306"></a>04306 
<a name="l04323"></a><a class="code" href="_s_d_l2__gfx_primitives_8h.html#a247136a562abec2649718d38f5819b44">04323</a> <span class="keywordtype">int</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a20297b17afd1e3686589bf74ebd17482" title="Draw a thick line with alpha blending.">thickLineRGBA</a>(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
<a name="l04324"></a>04324 {
<a name="l04325"></a>04325         <span class="keywordtype">int</span> result;
<a name="l04326"></a>04326         <span class="keywordtype">int</span> wh;
<a name="l04327"></a>04327         <a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html" title="The structure passed to the internal Murphy iterator.">SDL2_gfxMurphyIterator</a> m;
<a name="l04328"></a>04328 
<a name="l04329"></a>04329         <span class="keywordflow">if</span> (renderer == NULL) {
<a name="l04330"></a>04330                 <span class="keywordflow">return</span> -1;
<a name="l04331"></a>04331         }
<a name="l04332"></a>04332         <span class="keywordflow">if</span> (width &lt; 1) {
<a name="l04333"></a>04333                 <span class="keywordflow">return</span> -1;
<a name="l04334"></a>04334         }
<a name="l04335"></a>04335 
<a name="l04336"></a>04336         <span class="comment">/* Special case: thick &quot;point&quot; */</span>
<a name="l04337"></a>04337         <span class="keywordflow">if</span> ((x1 == x2) &amp;&amp; (y1 == y2)) {
<a name="l04338"></a>04338                 wh = width / 2;
<a name="l04339"></a>04339                 <span class="keywordflow">return</span> <a class="code" href="_s_d_l2__gfx_primitives_8c.html#a6c26ea8c03d1092f917665a182b91963" title="Draw box (filled rectangle) with blending.">boxRGBA</a>(renderer, x1 - wh, y1 - wh, x2 + width, y2 + width, r, g, b, a);         
<a name="l04340"></a>04340         }
<a name="l04341"></a>04341 
<a name="l04342"></a>04342         <span class="comment">/*</span>
<a name="l04343"></a>04343 <span class="comment">        * Set color</span>
<a name="l04344"></a>04344 <span class="comment">        */</span>
<a name="l04345"></a>04345         result = 0;
<a name="l04346"></a>04346         result |= SDL_SetRenderDrawBlendMode(renderer, (a == 255) ? SDL_BLENDMODE_NONE : SDL_BLENDMODE_BLEND);
<a name="l04347"></a>04347         result |= SDL_SetRenderDrawColor(renderer, r, g, b, a);
<a name="l04348"></a>04348 
<a name="l04349"></a>04349         <span class="comment">/* </span>
<a name="l04350"></a>04350 <span class="comment">        * Draw</span>
<a name="l04351"></a>04351 <span class="comment">        */</span>
<a name="l04352"></a>04352         m.<a class="code" href="struct_s_d_l2__gfx_murphy_iterator.html#a966da7a60c4ea3ba301e26ccc5efe452">renderer</a> = renderer;
<a name="l04353"></a>04353         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#abc1df7ada979012cef99920e741cf559" title="Internal function to to draw wide lines with Murphy algorithm.">_murphyWideline</a>(&amp;m, x1, y1, x2, y2, width, 0);
<a name="l04354"></a>04354         <a class="code" href="_s_d_l2__gfx_primitives_8c.html#abc1df7ada979012cef99920e741cf559" title="Internal function to to draw wide lines with Murphy algorithm.">_murphyWideline</a>(&amp;m, x1, y1, x2, y2, width, 1);
<a name="l04355"></a>04355 
<a name="l04356"></a>04356         <span class="keywordflow">return</span>(0);
<a name="l04357"></a>04357 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
